Anand Bajpai Anand Bajpai - 16 days ago 4
Python Question

How to upload zip file through S3 signed URL

I am getting a signed URL from S3 and then tried a file upload using POSTMAN

File is getting uploaded but not full data as the result file is getting corrupted.

When I tried to do it via python requests module as

f= open("windows.zip")
d = f.read()
req = requests.put(s3URL, data=d)


The results are same.

But When I do

f = open("window.zip", "rb")
d = f.read()
req = requests.put(s3URL, data=d)


It works fine. Whole file get uploaded.

So any ideas do it via POSTMAN or without reading the file in binary mode.

because I don't have option to tell the client side that open your file binary mode.

Thanks

Answer

So When you open a file in Binary mode, you dont need any encoding. But on other hand direct upload needs a base64 encoding

refer this