The PUT request is different from the POST request. With a PUT request, access to the contents of the file can be obtained using request.data
or request.stream
. The first stores incoming data as a string, and request.stream
acts more like a file object, which makes it more suitable for binary data:
with open('uploaded_image.jpg', 'w') as f: f.write(request.stream.read())
source share