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

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

Introduction

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

Prototype

public HttpMethod getMethod() 

Source Link

Document

The HTTP method (GET, PUT, DELETE, HEAD) to be used 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>/* ww w  .j  a  va  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);
    }
}