Skip to content

Commit

Permalink
[Fixes #8551] raster uploads require sending the same file twice (#8586
Browse files Browse the repository at this point in the history
…) (#8594)

* [Fixes #8551] raster uploads require sending the same file twice

* [Fixes #8551] raster uploads require sending the same file twice

Co-authored-by: Alessio Fabiani <[email protected]>
  • Loading branch information
github-actions[bot] and Alessio Fabiani authored Jan 13, 2022
1 parent 7ddf753 commit 5899d51
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 18 deletions.
6 changes: 0 additions & 6 deletions geonode/tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,9 +247,6 @@ def upload_file(self, _file, perms=None):
# allow for that
if os.path.exists(file_path):
params[spatial_file] = open(file_path, 'rb')
elif ext.lower() == '.tif':
file_path = base + ext
params['tif_file'] = open(file_path, 'rb')

with open(_file, 'rb') as base_file:
params['base_file'] = base_file
Expand All @@ -264,9 +261,6 @@ def upload_file(self, _file, perms=None):
if isinstance(params.get(spatial_file), IOBase):
params[spatial_file].close()

if isinstance(params.get("tif_file"), IOBase):
params['tif_file'].close()

try:
return resp, resp.json()
except ValueError:
Expand Down
12 changes: 0 additions & 12 deletions geonode/upload/api/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,6 @@ def live_upload_file(self, _file):
# allow for that
if os.path.exists(file_path):
params[spatial_file] = open(file_path, 'rb')
elif ext.lower() == '.tif':
file_path = base + ext
params['tif_file'] = open(file_path, 'rb')

with open(_file, 'rb') as base_file:
params['base_file'] = base_file
Expand All @@ -240,9 +237,6 @@ def live_upload_file(self, _file):
if isinstance(params.get(spatial_file), IOBase):
params[spatial_file].close()

if isinstance(params.get("tif_file"), IOBase):
params['tif_file'].close()

try:
logger.error(f" -- response: {response.status_code} / {response.json()}")
return response, response.json()
Expand Down Expand Up @@ -275,9 +269,6 @@ def rest_upload_file(self, _file, username=GEONODE_USER, password=GEONODE_PASSWD
# allow for that
if os.path.exists(file_path):
params[spatial_file] = open(file_path, 'rb')
elif ext.lower() == '.tif':
file_path = base + ext
params['tif_file'] = open(file_path, 'rb')

with open(_file, 'rb') as base_file:
params['base_file'] = base_file
Expand All @@ -295,9 +286,6 @@ def rest_upload_file(self, _file, username=GEONODE_USER, password=GEONODE_PASSWD
if isinstance(params.get(spatial_file), IOBase):
params[spatial_file].close()

if isinstance(params.get("tif_file"), IOBase):
params['tif_file'].close()

try:
logger.error(f" -- response: {response.status_code} / {response.json()}")
return response, response.json()
Expand Down
2 changes: 2 additions & 0 deletions geonode/upload/upload_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ def validate_uploaded_files(cleaned, uploaded_files, field_spatial_types):
valid_extensions.append(extension)
except AttributeError:
pass
if not valid_extensions:
valid_extensions = [f"{base_ext.lower()}"]
return valid_extensions


Expand Down

0 comments on commit 5899d51

Please sign in to comment.