请更新元数据管理的文档,UserMetadata中不能存在中文,否则返回SignatureDoesNotMatch
RandyZ opened this issue · 0 comments
RandyZ commented
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