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 month ago355 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.

profile picture
EXPERT
shibata
answered a month ago
profile picture
EXPERT
reviewed a month ago
profile pictureAWS
EXPERT
reviewed a month 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.