我生成了一个 GCP 签名网址, header 中包含两个元数据值。
例如, ‘x-goog-meta-reviewer’:‘简’, ‘x-goog-meta-author’:’jack’
当我尝试使用 header 中设置的元数据将文件上传到生成的签名 URL 时。我收到 403 禁止请求。
但有趣的是,如果我只设置一个元数据,相同的代码可以正常工作 ‘x-goog-meta-reviewer’:‘简’ 在两个标题中。
尝试将文件上传到 Google 云时能否不发送两个元数据值?
最佳答案
当您构造 Canonical requests 时你应该记住 规范 header 如下:
1.Make all header names lowercase.
2.Sort all headers by header name using a lexicographical sort by code point value.
3.Separate each header with a newline (/n).
4.Eliminate duplicate header names by creating one header name with a comma-separated list of values. Be sure there is no whitespace between the values, and be sure that the order of the comma-separated list matches the order that the headers appear in your request. For more information, see RFC 7230 section 3.2.
5.Replace any folding whitespace or newlines (CRLF or LF) with a single space. For more information about folding whitespace, see RFC 7230, section 3.2.4..
6.Remove any whitespace around the colon that appears after the header name.
7.For example, using the custom header x-goog-acl: private without removing the space after the colon returns a 403 Forbidden error, because the request signature you calculate does not match the signature Google calculates.
因此,当您计算的请求签名与 Google 计算的签名不匹配时,您可能会收到 403 Forbidden 错误。
关于javascript - 尝试上传到使用多个元数据生成的 GCP 签名网址时收到 403,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59879804/