From 959f90e1490847165f2185b373799c2cbd772d1f Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Tue, 21 Jan 2025 11:40:59 -0600 Subject: Add "original-name" and "uploaded-file" to all successful responses. Since both the original file name, and the final computed file name could (and do) find use after the upload has completed, include them in all the success messages. --- uploader/files/views.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/uploader/files/views.py b/uploader/files/views.py index 10d52d4..8d81654 100644 --- a/uploader/files/views.py +++ b/uploader/files/views.py @@ -27,8 +27,11 @@ def resumable_upload_get(): }), 400 # If the complete target file exists, return 200 for all chunks. - if target_file(fileid).exists(): + _targetfile = target_file(fileid) + if _targetfile.exists(): return jsonify({ + "uploaded-file": _targetfile.name, + "original-name": filename, "chunk": chunk, "message": "The complete file already exists.", "statuscode": 200 @@ -74,6 +77,7 @@ def resumable_upload_post(): if _targetfile.exists(): return jsonify({ "uploaded-file": _targetfile.name, + "original-name": _uploadfilename, "message": "File was uploaded successfully!", "statuscode": 200 }), 200 @@ -93,6 +97,7 @@ def resumable_upload_post(): chunks_directory(_fileid).rmdir() return jsonify({ "uploaded-file": _targetfile.name, + "original-name": _uploadfilename, "message": "File was uploaded successfully!", "statuscode": 200 }), 200 -- cgit v1.2.3