Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
819 B
1
Indexable
Never
	private static URL generatePresignedUrl(String bucketName, String objectKey) {
		// TODO 6: Replace the solution with your own code
		// return Solution.generatePresignedUrl(s3ClientForStudentBuckets, bucketName, objectKey);
		
		// Set the presigned URL to expire after one hour.
        java.util.Date expiration = new java.util.Date();
        long expTimeMillis = Instant.now().toEpochMilli();
        expTimeMillis += 1000 * 60 * 15;
        expiration.setTime(expTimeMillis);
		
		GeneratePresignedUrlRequest generatePresignedUrlRequest =
                new GeneratePresignedUrlRequest(bucketName, objectKey)
                        .withMethod(HttpMethod.GET)
                        .withExpiration(expiration);
        return s3ClientForStudentBuckets.generatePresignedUrl(generatePresignedUrlRequest);
		
	}