Example usage for com.amazonaws.services.s3.model GeneratePresignedUrlRequest getExpiration

List of usage examples for com.amazonaws.services.s3.model GeneratePresignedUrlRequest getExpiration

Introduction

In this page you can find the example usage for com.amazonaws.services.s3.model GeneratePresignedUrlRequest getExpiration.

Prototype

public Date getExpiration() 

Source Link

Document

The expiration date at which point the new pre-signed URL will no longer be accepted by Amazon S3.

Usage

From source file:org.finra.herd.dao.impl.MockS3OperationsImpl.java

License:Apache License

/**
 * {@inheritDoc} <p/> <p> A mock implementation which generates a URL which reflects the given request. </p> <p> The URL is composed as such: </p> <p/>
 * <pre>//from ww w.ja  v  a  2s.  co m
 * https://{s3BucketName}/{s3ObjectKey}?{queryParams}
 * </pre>
 * <p> Where {@code queryParams} is the URL encoded list of parameters given in the request. </p> <p> The query params include: </p> TODO: list the query
 * params in the result.
 */
@Override
public URL generatePresignedUrl(GeneratePresignedUrlRequest generatePresignedUrlRequest, AmazonS3 s3) {
    String host = generatePresignedUrlRequest.getBucketName();
    StringBuilder file = new StringBuilder();
    file.append('/').append(generatePresignedUrlRequest.getKey());
    file.append("?method=").append(generatePresignedUrlRequest.getMethod());
    file.append("&expiration=").append(generatePresignedUrlRequest.getExpiration().getTime());
    try {
        return new URL("https", host, file.toString());
    } catch (MalformedURLException e) {
        throw new RuntimeException(e);
    }
}