Last active
October 26, 2017 00:47
-
-
Save x-blood/8b7d66017926ca8cc6ad69dfdf5c920a to your computer and use it in GitHub Desktop.
(AWS)EC2のWebApplicationからS3の署名付きURLを取得する方法
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Date expiration = new Date(); | |
long msec = expiration.getTime(); | |
msec += 1000 * 60 * 60; // 1 hour. | |
// 有効期限の設定(デフォルトは15分らしい) | |
expiration.setTime(msec); | |
GeneratePresignedUrlRequest generatePresignedUrlRequest = | |
new GeneratePresignedUrlRequest(bucketName, path); | |
// GET Request(POSTもできる) | |
generatePresignedUrlRequest.setMethod(HttpMethod.GET); | |
URL url = client.generatePresignedUrl(generatePresignedUrlRequest); | |
return url.toString(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment