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:

  const config = {
    header: {
        'Content-Type': 'image/jpeg'
    }
  };

  axios.put(url, photo.value, config)
  .catch(error => {
    console.log("Error");
  });


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:
        url = s3.generate_presigned_url('put_object',
                                             Params={'Bucket': bucket_name, 'Key': object_name},
                                            ExpiresIn=expiration,
                                            HttpMethod='PUT')


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/1
Was this page helpful?