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

后端 未结 6 1357
礼貌的吻别
礼貌的吻别 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:51

    Had the same issue, here is how you need to solve it,

    1. Extract the filename portion of the signed URL. Do a print that you are extracting your filename portion correctly with querystring parameters. This is critical.
    2. Encode to URI Encoding of the filename with query string parameters.
    3. Return the url from your lambda with encoded filename along with other path or from your node service.

    Now post from axios with that url, it will work.

    EDIT1: Your signature will also be invalid, if you pass in wrong content type.

    Please ensure that the content-type you have you create the pre-signed url is same as the one you are using it for put.

    Hope it helps.

提交回复
热议问题