admin管理员组文章数量:1289834
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.
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.
Share Improve this question asked Jun 3, 2017 at 7:53 Damien MonniDamien Monni 1,5483 gold badges16 silver badges28 bronze badges 5- 1 in terms of API design guidelines, A POST request is used to send data to the server, for example, customer information, file upload, etc. using HTML forms. And PUT request is used to replaces all current representations of the target resource with the uploaded content. – Pranav Patel Commented Jun 3, 2017 at 8:08
- Yes but my question is more AWS specific. I want the pros and cons of using both with AWS S3 – Damien Monni Commented Jun 3, 2017 at 8:12
-
The difference I noticed is that I can't restrict content-type and length server-side with PUT when I generate the signature. Question: Are you using Signature Version 2 or 4? A V4 signature can be identified by seeing
Authorization: AWS4-HMAC-SHA256 ...
if using headers orX-Amz-Algorithm=AWS4-HMAC-SHA256
if using the query string. – Michael - sqlbot Commented Jun 3, 2017 at 11:46 - I am using signature V4 – Damien Monni Commented Jun 3, 2017 at 12:15
- refer: bhupenderhbti.blogspot./2017/10/… – Balakrishnan Commented May 29, 2019 at 2:52
1 Answer
Reset to default 1Apart 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)
本文标签: javascriptAWS S3 should I use POST or PUT requests to upload a fileStack Overflow
版权声明:本文标题:javascript - AWS S3: should I use POST or PUT requests to upload a file? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741423901a2377963.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论