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

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

Introduction

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

Prototype

public String getBucketName() 

Source Link

Document

Returns the name of the bucket 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>// w  w w . ja v a  2s  .com
 * 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);
    }
}