update 优化 OSS私有桶的临时URL获取方法
Signed-off-by: 秋辞未寒 <545073804@qq.com>
This commit is contained in:
parent
8c57d694c5
commit
a2714fb9f7
@ -285,12 +285,12 @@ public class OssClient {
|
|||||||
* 获取私有URL链接
|
* 获取私有URL链接
|
||||||
*
|
*
|
||||||
* @param objectKey 对象KEY
|
* @param objectKey 对象KEY
|
||||||
* @param second 授权时间
|
* @param expiredTime 链接授权到期时间
|
||||||
*/
|
*/
|
||||||
public String getPrivateUrl(String objectKey, Integer second) {
|
public String getPrivateUrl(String objectKey, Duration expiredTime) {
|
||||||
// 使用 AWS S3 预签名 URL 的生成器 获取对象的预签名 URL
|
// 使用 AWS S3 预签名 URL 的生成器 获取对象的预签名 URL
|
||||||
URL url = presigner.presignGetObject(
|
URL url = presigner.presignGetObject(
|
||||||
x -> x.signatureDuration(Duration.ofSeconds(second))
|
x -> x.signatureDuration(expiredTime)
|
||||||
.getObjectRequest(
|
.getObjectRequest(
|
||||||
y -> y.bucket(properties.getBucketName())
|
y -> y.bucket(properties.getBucketName())
|
||||||
.key(objectKey)
|
.key(objectKey)
|
||||||
|
@ -262,7 +262,7 @@ public class SysOssServiceImpl implements ISysOssService, OssService {
|
|||||||
OssClient storage = OssFactory.instance(oss.getService());
|
OssClient storage = OssFactory.instance(oss.getService());
|
||||||
// 仅修改桶类型为 private 的URL,临时URL时长为120s
|
// 仅修改桶类型为 private 的URL,临时URL时长为120s
|
||||||
if (AccessPolicyType.PRIVATE == storage.getAccessPolicy()) {
|
if (AccessPolicyType.PRIVATE == storage.getAccessPolicy()) {
|
||||||
oss.setUrl(storage.getPrivateUrl(oss.getFileName(), 120));
|
oss.setUrl(storage.getPrivateUrl(oss.getFileName(), Duration.ofSeconds(120)));
|
||||||
}
|
}
|
||||||
return oss;
|
return oss;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user