1).连接OSS时候发生 NoSuchBucket
的错误, 请检查 Endpoint
是否正确。
2).使用了addEndpoint()
之后,就不需要进行setSysEndPoint()
;
3).STS的服务,EndPoint
应该也是STS的EndPoint
,而不能用Oss的EndPoint
;
4).STS传递过来的为UTC时间,如果要精细管理本地的token生命周期,那么最好转换成Long来进行比较;
5).一个ST,可以在其生效期内反复使用,相当于,一个app的所有用户可共用一个ST,来进行对某个OSS的访问;
以下是实际代码 :
// 一定要是STS的EndPoint
DefaultProfile.addEndpoint("", "Sts", OurOssConfig.stsEndpoint);
// 账号的ID和AK
IClientProfile profile = DefaultProfile.getProfile("", OurOssConfig.accessKeyId,OurOssConfig.accessKeySecret)