Skip to content

Instantly share code, notes, and snippets.

@chrylis
Created October 15, 2015 22:25
Show Gist options
  • Save chrylis/c2227a54f4e5a84f9778 to your computer and use it in GitHub Desktop.
Save chrylis/c2227a54f4e5a84f9778 to your computer and use it in GitHub Desktop.
S3 download signer
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