以下为错误提示:
This XML file does not appear to have any style information associated with it. The document tree is shown below.
<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>54544E4165CC6367EB0DD555</RequestId>
<HostId>image.soso88.org</HostId>
</Error>
-----------------------------------------------------------分割线-----------------------------------------------------
以下为代码片段:
/**
* 实现阿里云签名实现以及相关URL请求必要的URL参数,参数使用在URL的?号后面部分。
* 此处实现的URL是基于网络抓取频道下的URL链接
* @param key 访问的资源文件名
* @param param 访问的资源图片处理参数(OSS协议对图片的处理)
* @param time 访问的URL有效时间,过期后访问URL无效
* @return 返回最终的URL参数(OSS协议)
* @throws UnsupportedEncodingException
*/
public static String getDownLoadUrlStr(String key,String param, int time) throws UnsupportedEncodingException{
StringBuffer urlBuf = new StringBuffer();
int realtime = DateUtilExt.parseNowToInt()+time;
urlBuf.append("OSSAccessKeyId=").append(URLEncoder.encode(ACCESS_ID, "utf-8"));
urlBuf.append("&");
urlBuf.append("Expires=").append(realtime);
urlBuf.append("&");
String canonicalizedResource = "/" + downloadBucketName + "/" + key + "@" + param;
urlBuf.append("Signature=").append(URLEncoder.encode(getSignature(canonicalizedResource, realtime), "utf-8"));
return urlBuf.toString();
}
public static final String GET_METHOD = "GET"; private static String getSignature(String canonicalizedResource, int time){
StringBuffer buf = new StringBuffer(); buf.append(GET_METHOD);
buf.append("\n"); buf.append("\n");
buf.append("\n"); buf.append(time);
buf.append("\n"); buf.append(canonicalizedResource);
return Codec.encodeBASE64(buf.toString()); }
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。