Class GeneratePresignedUrlRequest
- All Implemented Interfaces:
ReadLimitInfo
,SSECustomerKeyProvider
,Serializable
,Cloneable
Contains options to generate a pre-signed URL for an Amazon S3 resource.
Pre-signed URLs allow clients to form a URL for an Amazon S3 resource and sign it with the current AWS security credentials. A pre-signed URL may be passed around for other users to access the resource without providing them access to an account's AWS security credentials.
-
Field Summary
Fields inherited from class com.amazonaws.AmazonWebServiceRequest
NOOP
-
Constructor Summary
ConstructorsConstructorDescriptionGeneratePresignedUrlRequest
(String bucketName, String key) Creates a new request for generating a pre-signed URL that can be used as part of an HTTP GET request to access the Amazon S3 object stored under the specified key in the specified bucket.GeneratePresignedUrlRequest
(String bucketName, String key, HttpMethod method) Creates a new request for generating a pre-signed URL that can be used as part of an HTTP request to access the specified Amazon S3 resource. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addRequestParameter
(String key, String value) Adds an additional request parameter to be included in the pre-signed URL.Returns the name of the bucket involved in this request.Gets the expected content-md5 header of the request.Gets the expected content-type of the request.The expiration date at which point the new pre-signed URL will no longer be accepted by Amazon S3.getKey()
Returns the key of the object involved in this request.Returns the KMS customer key id used for server side encryption; or null if there is none.The HTTP method (GET, PUT, DELETE, HEAD) to be used in this request.Returns the complete map of additional request parameters to be included in the pre-signed URL.Returns the headers to be overridden in the service response.Returns the SSE algorithm used for SSE (with server side key); or null if SSE (with server side key) is not in use.Returns the optional customer-provided server-side encryption key to use to encrypt the uploaded object.boolean
Returns true if zero byte content is to be used for generating pre-signed URL; false otherwise.void
Rejects any illegal input (as attributes of this request) by the user.void
setBucketName
(String bucketName) Sets the name of the bucket involved in this request.void
setContentMd5
(String contentMd5) Sets the expected content-md5 header of the request.void
setContentType
(String contentType) Sets the expected content-type of the request.void
setExpiration
(Date expiration) Sets the expiration date at which point the new pre-signed URL will no longer be accepted by Amazon S3.void
Sets the key of the object involved in this request.void
setKmsCmkId
(String kmsCmkId) Sets the KMS customer key id used for server side encryption.void
setMethod
(HttpMethod method) Sets the HTTP method (GET, PUT, DELETE, HEAD) to be used in this request.void
setResponseHeaders
(ResponseHeaderOverrides responseHeaders) Sets the headers to be overridden in the service response.void
setSSEAlgorithm
(SSEAlgorithm sseAlgorithm) Sets the SSE algorithm for server side encryption.void
setSSEAlgorithm
(String sseAlgorithm) Sets the SSE algorithm for server side encryption.void
setSSECustomerKey
(SSECustomerKey sseCustomerKey) Sets the customer-provided server-side encryption key to use as part of the generated pre-signed URL.void
setSSECustomerKeyAlgorithm
(SSEAlgorithm sseAlgorithm) Sets the use of SSE-C (Server Side Encryption with Customer Key) using the given encryption algorithm.void
setZeroByteContent
(boolean zeroByteContent) Sets if zero byte content is to be used for generating pre-signed URL.withBucketName
(String bucketName) Sets the name of the bucket involved in this request, and returns this request object to enable additional method calls to be chained together.withContentMd5
(String contentMd5) Sets the expected content-md5 header of the request and returns this object, for method chaining.withContentType
(String contentType) Sets the expected content-type of the request and returns this object, for method chaining.withExpiration
(Date expiration) Sets the expiration date at which point the new pre-signed URL will no longer be accepted by Amazon S3, and returns this request object to enable additional method calls to be chained together.Sets the key of the object involved in this request, and returns this request object to enable additional method calls to be chained together.withKmsCmkId
(String kmsCmkId) Fluent API forsetKmsCmkId(String)
withMethod
(HttpMethod method) Sets the HTTP method (GET, PUT, DELETE, HEAD) to be used in this request, and returns this request object to enable additional method calls to be chained together.withResponseHeaders
(ResponseHeaderOverrides responseHeaders) Sets the headers to be overridden in the service response and returns this object, for method chaining.withSSEAlgorithm
(SSEAlgorithm sseAlgorithm) Fluent API forsetSSEAlgorithm(SSEAlgorithm)
withSSEAlgorithm
(String sseAlgorithm) Fluent API forsetSSEAlgorithm(String)
withSSECustomerKey
(SSECustomerKey sseKey) Sets the customer-provided server-side encryption key to use as part of the generated pre-signed URL, and returns the updated request object so that additional method calls can be chained together.withSSECustomerKeyAlgorithm
(SSEAlgorithm algorithm) Fluent method forsetSSECustomerKeyAlgorithm(SSEAlgorithm)
.withZeroByteContent
(boolean zeroByteContent) Fluent method forsetZeroByteContent(boolean)
.Methods inherited from class com.amazonaws.AmazonWebServiceRequest
clone, copyBaseTo, getCloneRoot, getCloneSource, getCustomQueryParameters, getCustomRequestHeaders, getGeneralProgressListener, getReadLimit, getRequestClientOptions, getRequestCredentials, getRequestCredentialsProvider, getRequestMetricCollector, getSdkClientExecutionTimeout, getSdkRequestTimeout, putCustomQueryParameter, putCustomRequestHeader, setGeneralProgressListener, setRequestCredentials, setRequestCredentialsProvider, setRequestMetricCollector, setSdkClientExecutionTimeout, setSdkRequestTimeout, withGeneralProgressListener, withRequestMetricCollector, withSdkClientExecutionTimeout, withSdkRequestTimeout
-
Constructor Details
-
GeneratePresignedUrlRequest
Creates a new request for generating a pre-signed URL that can be used as part of an HTTP GET request to access the Amazon S3 object stored under the specified key in the specified bucket.- Parameters:
bucketName
- The name of the bucket containing the desired Amazon S3 object.key
- The key under which the desired Amazon S3 object is stored.
-
GeneratePresignedUrlRequest
Creates a new request for generating a pre-signed URL that can be used as part of an HTTP request to access the specified Amazon S3 resource.
When specifying an HTTP method, you must send the pre-signed URL with the same HTTP method in order to successfully use the pre-signed URL.
- Parameters:
bucketName
- The name of the Amazon S3 bucket involved in the operation.key
- The key of the Amazon S3 object involved in the operation.method
- The HTTP method (GET, PUT, DELETE, HEAD) to be used in the request when the pre-signed URL is used.
-
-
Method Details
-
getKmsCmkId
Returns the KMS customer key id used for server side encryption; or null if there is none. -
setKmsCmkId
Sets the KMS customer key id used for server side encryption.Note S3 does not require HTTP header “x-amz-server-side-encryption-aws-kms-key-id” to be always present (a default key ID will be used if this header is not present).
It is also possible to set the header to “alias/aws/s3” to refer to the default KMS CMK ID.
-
withKmsCmkId
Fluent API forsetKmsCmkId(String)
-
getSSEAlgorithm
Returns the SSE algorithm used for SSE (with server side key); or null if SSE (with server side key) is not in use. -
setSSEAlgorithm
Sets the SSE algorithm for server side encryption.- Parameters:
currently
- supported values: "AES256" or "aws:kms".
-
withSSEAlgorithm
Fluent API forsetSSEAlgorithm(String)
-
setSSEAlgorithm
Sets the SSE algorithm for server side encryption.- Parameters:
currently
- supported values: "AES256" or "aws:kms".
-
withSSEAlgorithm
Fluent API forsetSSEAlgorithm(SSEAlgorithm)
-
getMethod
The HTTP method (GET, PUT, DELETE, HEAD) to be used in this request. The same HTTP method must be used in the request when the pre-signed URL is used.- Returns:
- The HTTP method (GET, PUT, DELETE, HEAD) to be used in this request and when the pre-signed URL is used.
-
setMethod
Sets the HTTP method (GET, PUT, DELETE, HEAD) to be used in this request. The same HTTP method must be used in the request when the pre-signed URL is used.- Parameters:
method
- The HTTP method (GET, PUT, DELETE, HEAD) to be used in this request.
-
withMethod
Sets the HTTP method (GET, PUT, DELETE, HEAD) to be used in this request, and returns this request object to enable additional method calls to be chained together.The same HTTP method must be used in the request when the pre-signed URL is used.
- Parameters:
method
- The HTTP method (GET, PUT, DELETE, HEAD) to be used in this request.- Returns:
- The updated request object, so that additional method calls can be chained together.
-
getBucketName
Returns the name of the bucket involved in this request.- Returns:
- the name of the bucket involved in this request.
-
setBucketName
Sets the name of the bucket involved in this request.- Parameters:
bucketName
- the name of the bucket involved in this request.
-
withBucketName
Sets the name of the bucket involved in this request, and returns this request object to enable additional method calls to be chained together.- Parameters:
bucketName
- the name of the bucket involved in this request.- Returns:
- The updated request object, so that additional method calls can be chained together.
-
getKey
Returns the key of the object involved in this request.- Returns:
- The key of the object involved in this request.
-
setKey
Sets the key of the object involved in this request.- Parameters:
key
- the key of the object involved in this request.
-
withKey
Sets the key of the object involved in this request, and returns this request object to enable additional method calls to be chained together.- Parameters:
key
- the key of the object involved in this request.- Returns:
- The updated request object, so that additional method calls can be chained together.
-
getExpiration
The expiration date at which point the new pre-signed URL will no longer be accepted by Amazon S3. If not specified, a default value will be supplied.- Returns:
- The expiration date at which point the new pre-signed URL will no longer be accepted by Amazon S3.
-
setExpiration
Sets the expiration date at which point the new pre-signed URL will no longer be accepted by Amazon S3. If not specified, a default value will be supplied.- Parameters:
expiration
- The expiration date at which point the new pre-signed URL will no longer be accepted by Amazon S3.
-
withExpiration
Sets the expiration date at which point the new pre-signed URL will no longer be accepted by Amazon S3, and returns this request object to enable additional method calls to be chained together.If not specified, a default value will be supplied.
- Parameters:
expiration
- The expiration date at which point the new pre-signed URL will no longer be accepted by Amazon S3.- Returns:
- The updated request object, so that additional method calls can be chained together.
-
addRequestParameter
Adds an additional request parameter to be included in the pre-signed URL. Adding additional request parameters enables more advanced pre-signed URLs, such as accessing Amazon S3's torrent resource for an object, or for specifying a version ID when accessing an object.- Parameters:
key
- The name of the request parameter, as it appears in the URL's query string (e.g. versionId).value
- The (optional) value of the request parameter being added.
-
getRequestParameters
Returns the complete map of additional request parameters to be included in the pre-signed URL.- Returns:
- The complete map of additional request parameters to be included in the pre-signed URL.
-
getResponseHeaders
Returns the headers to be overridden in the service response.- Returns:
- the headers to be overridden in the service response.
-
setResponseHeaders
Sets the headers to be overridden in the service response.- Parameters:
responseHeaders
- The headers to be overridden in the service response.
-
withResponseHeaders
Sets the headers to be overridden in the service response and returns this object, for method chaining.- Parameters:
responseHeaders
- The headers to be overridden in the service response.- Returns:
- This
GeneratePresignedUrlRequest
for method chaining.
-
getContentType
Gets the expected content-type of the request. The content-type is included in the signature.- Returns:
- The expected content-type
-
setContentType
Sets the expected content-type of the request. The content-type is included in the signature.- Parameters:
contentType
- The expected content-type
-
withContentType
Sets the expected content-type of the request and returns this object, for method chaining.- Parameters:
contentType
- The expected content-type- Returns:
- This
GeneratePresignedUrlRequest
for method chaining.
-
getContentMd5
Gets the expected content-md5 header of the request. This header value will be included when calculating the signature, and future requests must include the same content-md5 header value to access the presigned URL.- Returns:
- The expected content-md5 header value.
-
setContentMd5
Sets the expected content-md5 header of the request. This header value will be included when calculating the signature, and future requests must include the same content-md5 header value to access the presigned URL.- Parameters:
contentMd5
- The expected content-md5 header value.
-
withContentMd5
Sets the expected content-md5 header of the request and returns this object, for method chaining.- Parameters:
contentMd5
- The expected content-md5 header value.- Returns:
- This
GeneratePresignedUrlRequest
for method chaining.
-
getSSECustomerKey
Description copied from interface:SSECustomerKeyProvider
Returns the optional customer-provided server-side encryption key to use to encrypt the uploaded object.- Specified by:
getSSECustomerKey
in interfaceSSECustomerKeyProvider
- Returns:
- The optional customer-provided server-side encryption key to use to encrypt the uploaded object.
-
setSSECustomerKey
Sets the customer-provided server-side encryption key to use as part of the generated pre-signed URL.- Parameters:
sseCustomerKey
- The customer-provided server-side encryption key to use as part of the generated pre-signed URL.
-
withSSECustomerKey
Sets the customer-provided server-side encryption key to use as part of the generated pre-signed URL, and returns the updated request object so that additional method calls can be chained together.- Parameters:
sseKey
- The customer-provided server-side encryption key to use as part of the generated pre-signed URL.- Returns:
- This updated request object so that additional method calls can be chained together.
-
setSSECustomerKeyAlgorithm
Sets the use of SSE-C (Server Side Encryption with Customer Key) using the given encryption algorithm.- Parameters:
sseAlgorithm
- The server-side encryption algorithm to use with this customer-provided server-side encryption key; or null if SSE-C is disabled. "AES256" is currently the only supported SSE-C encryption algorithm.
-
withSSECustomerKeyAlgorithm
Fluent method forsetSSECustomerKeyAlgorithm(SSEAlgorithm)
. -
isZeroByteContent
public boolean isZeroByteContent()Returns true if zero byte content is to be used for generating pre-signed URL; false otherwise. -
setZeroByteContent
public void setZeroByteContent(boolean zeroByteContent) Sets if zero byte content is to be used for generating pre-signed URL. -
withZeroByteContent
Fluent method forsetZeroByteContent(boolean)
. -
rejectIllegalArguments
public void rejectIllegalArguments()Rejects any illegal input (as attributes of this request) by the user.- Throws:
IllegalArgumentException
- if there is illegal input from the user.
-