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

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

Introduction

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

Prototype

public String getKey() 

Source Link

Document

Returns the key of the object involved in this request.

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   w w w  . j av a  2s  .c  o  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);
    }
}