diff --git a/sample/layman.layer/small_layer.zip b/sample/layman.layer/small_layer.zip new file mode 100644 index 000000000..92a7eb843 Binary files /dev/null and b/sample/layman.layer/small_layer.zip differ diff --git a/src/layman/layer/db/tasks.py b/src/layman/layer/db/tasks.py index 076a48c96..87ffd06c2 100644 --- a/src/layman/layer/db/tasks.py +++ b/src/layman/layer/db/tasks.py @@ -40,7 +40,7 @@ def refresh_table( if self.is_aborted(): raise AbortedException - main_filepath = get_layer_main_file_path(workspace, layername) + main_filepath = get_layer_main_file_path(workspace, layername, gdal_format=True) process = db.import_layer_vector_file_async(workspace, layername, main_filepath, crs_id) while process.poll() is None and not self.is_aborted(): pass diff --git a/src/layman/layer/rest_workspace_layers.py b/src/layman/layer/rest_workspace_layers.py index d9cc79eff..0ea32e2ec 100644 --- a/src/layman/layer/rest_workspace_layers.py +++ b/src/layman/layer/rest_workspace_layers.py @@ -8,7 +8,7 @@ from layman.authz import authorize_workspace_publications_decorator from layman.common import redis as redis_util, rest as rest_common from . import util, LAYER_TYPE, LAYER_REST_PATH_NAME -from .filesystem import input_file, input_style, input_chunk, uuid +from .filesystem import input_file, input_style, input_chunk, uuid, util as fs_util bp = Blueprint('rest_workspace_layers', __name__) @@ -41,12 +41,15 @@ def post(workspace): # FILE use_chunk_upload = False + zipped_file = None files = [] if 'file' in request.files: files = [ f for f in request.files.getlist("file") if len(f.filename) > 0 ] + if len(files) == 1 and input_file.get_compressed_main_file_extension(files[0].filename): + zipped_file = files[0] if len(files) == 0 and len(request.form.getlist('file')) > 0: files = [ filename for filename in request.form.getlist('file') @@ -79,6 +82,8 @@ def post(workspace): # FILE NAMES if use_chunk_upload: filenames = files + elif zipped_file: + filenames = fs_util.get_filenames_from_zip_storage(zipped_file) else: filenames = [f.filename for f in files] file_type = input_file.get_file_type(input_file.get_main_file_name(filenames)) @@ -153,8 +158,14 @@ def post(workspace): }) else: try: - input_file.save_layer_files( - workspace, layername, files, check_crs) + if zipped_file: + input_file.save_layer_zip_file( + workspace, layername, zipped_file, + ) + else: + input_file.save_layer_files( + workspace, layername, files, check_crs + ) except BaseException as exc: uuid.delete_layer(workspace, layername) input_file.delete_layer(workspace, layername) diff --git a/tests/dynamic_data/publications.py b/tests/dynamic_data/publications.py index 841718e71..f567809db 100644 --- a/tests/dynamic_data/publications.py +++ b/tests/dynamic_data/publications.py @@ -37,4 +37,30 @@ ], }, ], + Publication(consts.COMMON_WORKSPACE, consts.LAYER_TYPE, 'zipped_sld'): [ + { + consts.KEY_ACTION: { + consts.KEY_CALL: Action(process_client.publish_workspace_publication, { + 'file_paths': ['sample/layman.layer/small_layer.zip'], + }), + consts.KEY_RESPONSE_ASSERTS: [ + Action(processing.response.valid_post, dict()), + ], + }, + consts.KEY_FINAL_ASSERTS: [ + *publication.IS_LAYER_COMPLETE_AND_CONSISTENT, + Action(publication.internal.correct_values_in_detail, { + 'exp_publication_detail': { + **predefined_infos.BASIC_SLD_LAYER, + '_file': { + 'path': '/layman_data_test/workspaces/dynamic_test_workspace/layers/zipped_sld/input_file/zipped_sld.zip/small_layer.geojson' + }, + 'file': { + 'path': 'layers/zipped_sld/input_file/zipped_sld.zip/small_layer.geojson' + }, + }, + }), + ], + }, + ] }