Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

请更新元数据管理的文档,UserMetadata中不能存在中文,否则返回SignatureDoesNotMatch #456

Open
RandyZ opened this issue Feb 10, 2023 · 0 comments

Comments

@RandyZ
Copy link

RandyZ commented Feb 10, 2023

rawMetaData.put("zipInnerName", HttpUtil.urlEncode(objectInfo.getResourceName(), OSSConstants.DEFAULT_CHARSET_NAME));
rawMetaData.put("fileMd5", objectInspectSupporter.md5());
rawMetaData.put("fileLength", objectInspectSupporter.length().toString());
metadata.setUserMetadata(rawMetaData);

ResourceName如果有中文字符,由于默认使用了ISO编码,导致字符乱码,猜测服务端验签的时候出现了签名不一致的问题

<?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>
  <RequestId>63E5DDF48BF5AE3431F9E8C1</RequestId>
  <HostId>ddi-data.oss-cn-zhangjiakou.aliyuncs.com</HostId>
  <OSSAccessKeyId>L....</OSSAccessKeyId>
  <SignatureProvided>....</SignatureProvided>
  <StringToSign>PUT


Fri, 10 Feb 2023 06:02:28 GMT
x-oss-copy-source:/ddi-data/.....%2Ftest%2F%E6%89%93%E5%8C%85%E6%B5%8B%E8%AF%95%E6%96%87%E4%BB%B6_079TQSSZLC740test.csv.zip
x-oss-meta-filelength:164
x-oss-meta-filemd5:cdf16d5857d113b456e2d65797f0071f
x-oss-meta-filename:�??�??�?�?�??件_079TQSSZLC740test.csv
x-oss-metadata-directive:REPLACE
/.../打包测试文件_079TQSSZLC740test.csv.zip</StringToSign>
  <StringToSignBytes>123123</StringToSignBytes>
</Error>

请更新文档说明这一点,个人建议的解决方案在SDK内增加编解码

临时方案

HttpUtil.urlEncode(objectInfo.getResourceName(), OSSConstants.DEFAULT_CHARSET_NAME)

读取自定义Meta的时候使用decode

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant