我使用以下代码生成允许从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?
暂无答案!
目前还没有任何答案,快来回答吧!