Skip to content
Snippets Groups Projects
Verified Commit 2f5272ea authored by Peter Stanko's avatar Peter Stanko
Browse files

Fixes in upload

parent ae390380
No related branches found
No related tags found
1 merge request!13Cascade everywhere
......@@ -189,7 +189,7 @@ class SubmissionResultFiles(Resource):
permissions.check_component(client)])
task = upload_results_to_storage(submission)
return {'new_task': task}
return {'new_task': task.id}
@submissions_namespace.route('/<string:sid>/resubmit')
......
......@@ -170,15 +170,20 @@ def send_file_or_zip(storage_entity):
def upload_file_is_allowed(file):
extension = Path(file.filename).suffix
if not extension == 'zip':
log.debug(f"[ZIP] Extension for {file.filename}: {extension}")
if not extension == '.zip':
raise errors.PortalAPIError(
400,
f"File with extension \"{extension}\" is not allowed: #{file.filename}"
)
def upload_files_to_storage(file):
filename = secure_filename(file.filename)
path = Path(storage.results.workspace_path / 'uploads' / filename)
uploads = storage.results.workspace_path / 'uploads'
if not uploads.exists():
uploads.mkdir(parents=True)
path = uploads / filename
file.save(str(path))
log.info(f"[UPLOAD] Uploading file to {filename} to {path}")
return path
......@@ -186,7 +191,7 @@ def upload_files_to_storage(file):
def upload_results_to_storage(submission):
path = get_upload_file_path()
task = tasks.upload_results_to_storage.delay(submission.id, path=path)
task = tasks.upload_results_to_storage.delay(submission.id, path=str(path))
return task
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment