Adrian Adrian - 1 year ago 92
HTTP Question

PUT request to upload a file not working in Flask

I am working on a web application using Flask. One of the views is supposed to accept uploaded files through PUT requests, however I only can get POST requests with

$ curl -F upload=@filename URL
to work properly. With PUT requests such as
$ curl --upload-file filenname URL
ImmutableMultiDict is empty. Am I missing something in Flask or maybe with using curl?

Answer Source

PUT request is way different compared to POST request. With PUT request the file contents can be accessed using either or The first one stores incoming data as string, while acts more like a file object, making it more suitable for binary data:

with open('uploaded_image.jpg', 'w') as f:
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download