Created
October 15, 2015 22:25
-
-
Save chrylis/c2227a54f4e5a84f9778 to your computer and use it in GitHub Desktop.
S3 download signer
This file contains hidden or 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
package com.artsquare.studio.img.s3.signature | |
import groovy.transform.CompileStatic | |
import org.jets3t.service.S3Service | |
import org.jets3t.service.impl.rest.httpclient.RestS3Service | |
import org.jets3t.service.security.AWSCredentials | |
import com.artsquare.studio.config.StudioApplicationInfo | |
import com.artsquare.studio.img.s3.S3ImageLocation | |
@CompileStatic | |
class S3DownloadLinkSignerImpl implements S3DownloadLinkSigner { | |
final S3Service s3Service | |
final boolean useBucketAsHost | |
S3DownloadLinkSignerImpl(StudioApplicationInfo.S3 s3Config, AWSCredentials credentials) { | |
useBucketAsHost = s3Config.useBucketAsHost | |
s3Service = new RestS3Service(credentials) | |
} | |
@Override | |
String createDownloadUrl(S3ImageLocation location, Date expiration) { | |
s3Service.createSignedGetUrl(location.bucket, location.key, expiration, useBucketAsHost) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment