tencent cos 小改, 过期时间判断

This commit is contained in:
duandazhi 2021-07-30 09:44:52 +08:00
parent 8527b0233d
commit c51ecdd680
2 changed files with 11 additions and 1 deletions

View File

@ -109,7 +109,7 @@ public class TencentCosConfig {
* 2公共读 * 2公共读
* 3公共读写 * 3公共读写
*/ */
private Long expiryDuration = 32400L; private Long expiryDuration = -1L;
public String getAccessKey() { public String getAccessKey() {
return accessKey; return accessKey;
@ -152,6 +152,10 @@ public class TencentCosConfig {
} }
public Long getExpiryDuration() { public Long getExpiryDuration() {
if (expiryDuration != -1 && expiryDuration < 0) {
// 最小是1秒
expiryDuration = 1L;
}
return expiryDuration; return expiryDuration;
} }

View File

@ -162,6 +162,12 @@ public class TencentCosServiceImpl implements IDfsService {
*/ */
@Override @Override
public String presignedUrl(String fileUrl) { public String presignedUrl(String fileUrl) {
if (StringUtils.isBlank(fileUrl)) {
return fileUrl;
}
if (config.getExpiryDuration() == -1) {
return fileUrl;
}
// 存储桶的命名格式为 BucketName-APPID此处填写的存储桶名称必须为此格式 // 存储桶的命名格式为 BucketName-APPID此处填写的存储桶名称必须为此格式
String bucketName = config.getBucketName(); String bucketName = config.getBucketName();
if (StringUtils.isBlank(config.getBucketName())) { if (StringUtils.isBlank(config.getBucketName())) {