fix(upload): preserve fields in multipart fallback
Build and Push Docker Container / build-and-push (push) Successful in 1m40s
Build and Push Docker Container / build-and-push (push) Successful in 1m40s
- Recover regular multipart fields when the file part is not exposed through request.files. - Preserve expires and note values for browser uploads that need body-based file recovery. - Add parser coverage for file parts without filenames and recovered expiry fields. - Extend upload route tests to assert recovered uploads keep expiry metadata. - Bump NanoShare to 1.27.3.
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
from my_modules.upload_content import parse_multipart_upload_body, recover_file_from_multipart_body
|
||||
|
||||
def test_recovers_file_part_without_filename():
|
||||
boundary = '----nanoshare-test-boundary'
|
||||
body = (
|
||||
f'--{boundary}\r\n'
|
||||
'Content-Disposition: form-data; name="file"\r\n'
|
||||
'Content-Type: application/octet-stream\r\n'
|
||||
'\r\n'
|
||||
).encode() + b'hello upload' + (
|
||||
'\r\n'
|
||||
f'--{boundary}\r\n'
|
||||
'Content-Disposition: form-data; name="expires"\r\n'
|
||||
'\r\n'
|
||||
'7d\r\n'
|
||||
f'--{boundary}--\r\n'
|
||||
).encode()
|
||||
|
||||
uploaded = recover_file_from_multipart_body(body, boundary)
|
||||
parts = parse_multipart_upload_body(body, boundary)
|
||||
|
||||
assert uploaded is not None
|
||||
assert uploaded.filename == 'file'
|
||||
assert uploaded.mimetype == 'application/octet-stream'
|
||||
assert uploaded.stream.read() == b'hello upload'
|
||||
assert parts.fields == {'expires': '7d'}
|
||||
assert parts.file is not None
|
||||
assert parts.file.stream.read() == b'hello upload'
|
||||
Reference in New Issue
Block a user