mirror of
				https://github.com/dromara/RuoYi-Vue-Plus.git
				synced 2025-11-04 16:23:42 +08:00 
			
		
		
		
	@@ -284,13 +284,13 @@ public class OssClient {
 | 
			
		||||
    /**
 | 
			
		||||
     * 获取私有URL链接
 | 
			
		||||
     *
 | 
			
		||||
     * @param objectKey 对象KEY
 | 
			
		||||
     * @param second    授权时间
 | 
			
		||||
     * @param objectKey   对象KEY
 | 
			
		||||
     * @param expiredTime 链接授权到期时间
 | 
			
		||||
     */
 | 
			
		||||
    public String getPrivateUrl(String objectKey, Integer second) {
 | 
			
		||||
    public String getPrivateUrl(String objectKey, Duration expiredTime) {
 | 
			
		||||
        // 使用 AWS S3 预签名 URL 的生成器 获取对象的预签名 URL
 | 
			
		||||
        URL url = presigner.presignGetObject(
 | 
			
		||||
                x -> x.signatureDuration(Duration.ofSeconds(second))
 | 
			
		||||
                x -> x.signatureDuration(expiredTime)
 | 
			
		||||
                    .getObjectRequest(
 | 
			
		||||
                        y -> y.bucket(properties.getBucketName())
 | 
			
		||||
                            .key(objectKey)
 | 
			
		||||
 
 | 
			
		||||
@@ -262,7 +262,7 @@ public class SysOssServiceImpl implements ISysOssService, OssService {
 | 
			
		||||
        OssClient storage = OssFactory.instance(oss.getService());
 | 
			
		||||
        // 仅修改桶类型为 private 的URL,临时URL时长为120s
 | 
			
		||||
        if (AccessPolicyType.PRIVATE == storage.getAccessPolicy()) {
 | 
			
		||||
            oss.setUrl(storage.getPrivateUrl(oss.getFileName(), 120));
 | 
			
		||||
            oss.setUrl(storage.getPrivateUrl(oss.getFileName(), Duration.ofSeconds(120)));
 | 
			
		||||
        }
 | 
			
		||||
        return oss;
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user