How to upload to AWS S3 directly from browser using a pre-signed URL instead of credentials?

后端 未结 7 1148
天命终不由人
天命终不由人 2020-12-08 03:07

We\'d like to use Javascript AWS SDK to upload files to S3, but without using credentials at all. Uploading using credentials works, but we cannot generate an AWS IAM user f

7条回答
  •  -上瘾入骨i
    2020-12-08 03:18

    In project, on what I am working right now I have file uploads from client directly to S3, in my case it works in few steps:

    1. request pre-signed form with settings for upload, from server (it is signed on a server, because I can not pass access keys to the client, and also I need to apply some limitations to upload)
    2. upload file to S3 using XHR2 (for old browsers you can use hack with hidden iframe or browser plugins like flash)

    There is main code parts from it: https://gist.github.com/zxbodya/3cdabd9172bcc89f8ac5

提交回复
热议问题