When uploading a file using the API its same is always going to be
'unknown.<extension>', which is not good looking for file urls. This
patch proposes a custom header named 'X-File-Name' that allows to
specify a file name using an API client.
This changeset was tested with a local OAuth1 client.
)
mimetype = request.headers["Content-Type"]
- filename = mimetypes.guess_all_extensions(mimetype)
- filename = 'unknown' + filename[0] if filename else filename
+
+ if "X-File-Name" in request.headers:
+ filename = request.headers["X-File-Name"]
+ else:
+ filename = mimetypes.guess_all_extensions(mimetype)
+ filename = 'unknown' + filename[0] if filename else filename
+
file_data = FileStorage(
stream=io.BytesIO(request.data),
filename=filename,