[英]File Upload with Special Character(+) to S3 via API Gateway
我已經設置了一個與 S3 配合良好的 API 網關。 它還處理許多特殊字符,如space, -, %, etc.
唯一的問題是包含+
號的文件名。
試圖發送一個名為my+file.txt
的文件。
API 網關中沒有Lambda
。 它僅配置為 map 對S3
的請求。
我正在使用以下請求測試 API 網關:
有了這個請求,我得到以下錯誤響應:
SignatureDoesNotMatch
我們計算的請求簽名與您提供的簽名不匹配。 檢查您的密鑰和簽名方法。
下面是API網關請求的相關執行日志:
Thu Oct 17 07:06:56 UTC 2019 : HTTP Method: PUT, Resource Path: /to-device/my%2Bfile.txt
Thu Oct 17 07:06:56 UTC 2019 : Method request path: {bucket=to-device, object=my%2Bfile.txt}
Thu Oct 17 07:06:56 UTC 2019 : Method request query string: {}
Thu Oct 17 07:06:56 UTC 2019 : Method request headers: {}
Thu Oct 17 07:06:56 UTC 2019 : Method request body before transformations:
Thu Oct 17 07:06:57 UTC 2019 : Endpoint request URI: https://****.amazonaws.com/to-device/my+file.txt
Thu Oct 17 07:06:57 UTC 2019 : Endpoint request body after transformations:
Thu Oct 17 07:06:57 UTC 2019 : Sending request to https://****.amazonaws.com/to-device/my+file.txt
Thu Oct 17 07:06:57 UTC 2019 : Received response. Status: 403, Integration latency: 30 ms
Thu Oct 17 07:06:57 UTC 2019 : Endpoint response headers:
{
x-amz-request-id=*,
x-amz-id-2=*,
Content-Type=application/xml,
Transfer-Encoding=chunked,
Date=Thu,
17 Oct 2019 07:06:56 GMT,
Server=AmazonS3
}
Thu Oct 17 07:06:57 UTC 2019 : Endpoint response body before transformations: <?xml version="1.0" encoding="UTF-8"?>
<Error><Code>SignatureDoesNotMatch</Code><Message>The request signature we calculated does not match the signature you provided. Check your key and signing method.</Message><AWSAccessKeyId>
我認為 API 網關解碼輸入並將解碼后的請求映射到 S3 而不僅僅是傳遞它存在問題。
這里有什么問題?
如何將帶有+
登錄名的文件發送到 S3?
在這種情況下,您需要編碼 url + 符號將使用 %2B 進行編碼。 當你解碼時,你會得到+。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.