awss3预签名url下载多个文件

w7t8yxp5  于 2021-06-26  发布在  Java
关注(0)|答案(0)|浏览(258)

我使用以下代码生成允许从aws s3下载1个对象的url:

import com.amazonaws.services.s3.AmazonS3;
 import com.amazonaws.services.s3.model.GeneratePresignedUrlRequest;

 private AmazonS3 s3Client;

 public String getDownloadPhotoPresignedRequest(String bucketName, String objectKey) throws Exception {
        java.util.Date expiration = new java.util.Date();
        long expTimeMillis = expiration.getTime();
        expTimeMillis += 1000 * 60 * 5;
        expiration.setTime(expTimeMillis);

        // Generate the presigned URL.
        GeneratePresignedUrlRequest generatePresignedUrlRequest =
                new GeneratePresignedUrlRequest(bucketName, objectKey)
                        .withMethod(HttpMethod.GET)
                        .withExpiration(expiration);
        URL url = s3Client.generatePresignedUrl(generatePresignedUrlRequest);

        return url.toString();
    }

如何生成允许从s3下载多个文件的url?

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题