PUT object with presigned URL sets the incorrect Type in R2 object
Hey!
I'm trying to put an object to a bucket using presigned URL. But for some reason in the R2 I can always see the file type:
application/x-www-form-urlencoded
even when the file is a jpg, png,...
This is the code I'm using in nodejs:
The image is correctly uploaded, but the type in the R2 bucket is wrong as explained before. If I download the image, I can open it correctly and windows shows it as a .jpg as expected.
To generate the presigned URL I use python's boto3 package:
I saw this post of a user having a similar problem on your forums, but with no response: https://community.cloudflare.com/t/jpg-on-r2-served-with-wrong-content-type/484955/11 Reply
Note that setting the ContentType when creating the presigned URL just makes the request return a CORS error. E.g: this does not work:
Okay, this seems like a limitation of R2: https://github.com/boto/boto3/issues/934
Since R2 does not allow POST for uploading objects to the bucket, so there's no way around it. In any case, R2 should read the content-type of the request I'm making I believe.