Reputation: 1548
I would like to know the pros and cons of using POST or PUT request to upload a file to Amazon Web Services S3.
I've already read some SO question like this one, but I would like to know the specific differences when using the AWS API.
I managed to use both, but hardly see the difference. I am using both PUT and POST via AJAX and the XMLHTTPRequest object, to upload directly from the browser with a node.js backend generating the signature.
The difference I noticed is that I can't restrict content-type and length server-side with PUT when I generate the signature, but this could be because I am just learning it now.
Upvotes: 23
Views: 27462
Reputation: 19728
Apart from the differences you noticed, when using POST, the response you get contains The object key name. This is useful if you upload multiple objects in parallel, to identify which upload succeeded or not in the callback.
Also for access control, you can use POST and PUT differently (e.g Not allowing object modification, while only allowing creation)
Upvotes: 1