Skip to content

POST to S3 with signed URL always uploaded as binary/octet-stream

0

I'm using a signed url with POST

The file is uploaded fine but Content-Type is set as binary/octet-stream

This is the POST payload

key: foobar.png
AWSAccessKeyId: AKIAXXXXXXXXXXXXXXXX
policy:  validToken
signature: validSignature
file: (binary)
Content-Type: image/png

why the Content-Type is not used by S3?

If I set Content-Type: image/png in the header instead for the payload I get:

Bucket POST must be of the enclosure-type multipart/form-data

how can I set the correct value?

asked a year ago1.1K views
1 Answer
1
Accepted Answer

Unfortunately, this is not a solution.

I also believe that if you upload files to S3 via POST, the Content-Type setting is acceptable to include in the POST payload.

https://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-HTTPPOSTForms.html

This may sound silly, but you should try changing the order in which the form data is assembled, or try submitting the form manually using a curl command or something similar. For some reason, you may notice something wrong when you do so.

EXPERT
answered a year ago
EXPERT
reviewed a year ago
EXPERT
reviewed a year ago
  • Thanks to point me on the correct way. The link provided contains another link to the POST method, and is the key to solve the error: https://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectPOST.html "Important When constructing your request, make sure that the file field is the last field in the form.". Looks like AWS stop to process values when read de "file" field, so change the order, fix the issue.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.