Getting 403 (Forbidden) when uploading to S3 with a signed URL

后端 未结 6 1331
礼貌的吻别
礼貌的吻别 2021-02-07 03:30

I\'m trying to generate a pre-signed URL then upload a file to S3 through a browser. My server-side code looks like this, and it generates the URL:

let s3 = new          


        
6条回答
  •  [愿得一人]
    2021-02-07 03:52

    1) You might need to use S3V4 signatures depending on how the data is transferred to AWS (chunk versus stream). Create the client as follows:

    var s3 = new AWS.S3({
      signatureVersion: 'v4'
    });
    

    2) Do not add new headers or modify existing headers. The request must be exactly as signed.

    3) Make sure that the url generated matches what is being sent to AWS.

    4) Make a test request removing these two lines before signing (and remove the headers from your PUT). This will help narrow down your issue:

      ContentType: req.body.fileType,
      ACL: 'public-read'
    

提交回复
热议问题