public class GetObjectRequest extends AmazonWebServiceRequest implements SSECustomerKeyProvider, Serializable, ExpectedBucketOwnerRequest
Retrieves objects from Amazon S3. To use GET
, you must have READ
access to the object. If you
grant READ
access to the anonymous user, you can return the object without using an authorization header.
An Amazon S3 bucket has no directory hierarchy such as you would find in a typical computer file system. You can, however,
create a logical hierarchy by using object key names that imply a folder structure. For example, instead of naming an object
sample.jpg
, you can name it photos/2006/February/sample.jpg
.
To get an object from such a logical hierarchy, specify the full key name for the object in the GET
operation. For a virtual hosted-style request example, if you have the object photos/2006/February/sample.jpg
,
specify the resource as /photos/2006/February/sample.jpg
. For a path-style request example, if you have the
object photos/2006/February/sample.jpg
in the bucket named examplebucket
, specify the resource as
/examplebucket/photos/2006/February/sample.jpg
. For more information about request types, see
HTTP Host Header
Bucket Specification.
To distribute large files to many people, you can save bandwidth costs by using BitTorrent. For more information, see Amazon S3 Torrent. For more information about returning the ACL of an object, see GetObjectAcl.
If the object you are retrieving is stored in the S3 Glacier or S3 Glacier Deep Archive storage class, or S3 Intelligent-
Tiering Archive or S3 Intelligent-Tiering Deep Archive tiers, before you can retrieve the object you must first restore a copy
using RestoreObject. Otherwise, this
action returns an InvalidObjectState
error. For information about restoring archived objects, see
Restoring Archived Objects.
Encryption request headers, like x-amz-server-side-encryption
, should not be sent for GET requests if your
object uses server-side encryption with CMKs stored in Amazon Web Services KMS (SSE-KMS) or server-side encryption with Amazon
S3–managed encryption keys (SSE-S3). If your object does use these types of keys, you’ll get an HTTP 400 BadRequest error.
If you encrypt an object by using server-side encryption with customer-provided encryption keys (SSE-C) when you store the object in Amazon S3, then when you GET the object, you must use the following headers:
x-amz-server-side-encryption-customer-algorithm
x-amz-server-side-encryption-customer-key
x-amz-server-side-encryption-customer-key-MD5
For more information about SSE-C, see Server-Side Encryption (Using Customer-Provided Encryption Keys).
Assuming you have the relevant permission to read object tags, the
response also returns the x-amz-tagging-count
header that provides the count of number of tags associated with
the object. You can use GetObjectTagging
to retrieve the tag set associated with an object.
Permissions
You need the relevant read object (or version) permission for this operation. For more information,
see Specifying Permissions in a
Policy. If the object you request does not exist, the error Amazon S3 returns depends on whether you also have the
s3:ListBucket
permission.
If you have the s3:ListBucket
permission on the bucket, Amazon S3 will return an HTTP status code
404 (\"no such key\") error.
If you don’t have the s3:ListBucket
permission, Amazon S3 will return an HTTP status code 403
(\"access denied\") error.
Versioning
By default, the GET action returns the current version of an object. To return a different version, use the
versionId
subresource.
You need the s3:GetObjectVersion
permission to access a specific version of an object.
If the current version of the object is a delete marker, Amazon S3 behaves as if the object was deleted and
includes x-amz-delete-marker: true
in the response.
For more information about versioning, see PutBucketVersioning.
Overriding Response Header Values
There are times when you want to override certain response header values in a GET response. For example, you might override the Content-Disposition response header value in your GET request.
You can override values for a set of
response headers using the following query parameters. These response header values are sent only on a successful request,
that is, when status code 200 OK is returned. The set of headers you can override using these parameters is a subset of the
headers that Amazon S3 accepts when you create an object. The response headers that you can override for the GET response
are Content-Type
, Content-Language
, Expires
, Cache-Control
,
Content-Disposition
, and Content-Encoding
. To override these header values in the GET response, you
use the following request parameters.
You must sign the request, either using an Authorization header or a presigned URL, when using these parameters. They cannot be used with an unsigned (anonymous) request.
response-content-type
response-content-language
response-expires
response-cache-control
response-content-disposition
response-content-encoding
Additional Considerations about Request Headers
If both of the If-Match
and If-Unmodified-Since
headers are present in the request as
follows: If-Match
condition evaluates to true
, and; If-Unmodified-Since
condition
evaluates to false
; then, S3 returns 200 OK and the data requested.
If both of the If-None-Match
and If-Modified-Since
headers are present in the request as
follows: If-None-Match
condition evaluates to false
, and; If-Modified-Since
condition
evaluates to true
; then, S3 returns 304 Not Modified response code.
For more information about conditional requests, see RFC 7232.
The following operations are related to
GetObject
:
NOOP
Constructor and Description |
---|
GetObjectRequest(S3ObjectId s3ObjectId) |
GetObjectRequest(String bucketName,
String key)
Constructs a new
GetObjectRequest with all the required parameters. |
GetObjectRequest(String bucketName,
String key,
boolean isRequesterPays)
Constructs a new
GetObjectRequest with all the required
parameters. |
GetObjectRequest(String bucketName,
String key,
String versionId)
Constructs a new
GetObjectRequest with all the required parameters. |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object o) |
String |
getBucketName()
The bucket name containing the object.
|
String |
getExpectedBucketOwner()
Returns he account id of the expected bucket owner.
|
String |
getKey()
Gets the key under which the object to be downloaded is stored.
|
List<String> |
getMatchingETagConstraints()
Gets the optional list of ETag constraints that, when present, must
include a match for the object's current ETag in order for this
request to be executed.
|
Date |
getModifiedSinceConstraint()
Gets the optional modified constraint that restricts this
request to executing only if the object has been
modified after the specified date.
|
List<String> |
getNonmatchingETagConstraints()
Gets the optional list of ETag constraints that when present, must
not include a match for the object's current ETag in order for this
request to be executed.
|
Integer |
getPartNumber()
Returns the optional part number that indicates the part to be downloaded in a multipart object.
|
ProgressListener |
getProgressListener()
Deprecated.
use
AmazonWebServiceRequest.getGeneralProgressListener() instead. |
long[] |
getRange()
Gets the optional inclusive byte range within the desired object
that will be downloaded by this request.
|
ResponseHeaderOverrides |
getResponseHeaders()
Returns the headers to be overridden in the service response.
|
S3ObjectId |
getS3ObjectId()
Returns an immutable S3 object id.
|
SSECustomerKey |
getSSECustomerKey()
Returns the optional customer-provided server-side encryption key to use
to encrypt the uploaded object.
|
Date |
getUnmodifiedSinceConstraint()
Gets the optional unmodified constraint that restricts this
request to executing only if the object has not been
modified after the specified date.
|
String |
getVersionId()
Gets the optional version ID specifying which version of the object to
download.
|
int |
hashCode() |
boolean |
isRequesterPays()
Returns true if the user has enabled Requester Pays option when
downloading an object from Requester Pays Bucket; else false.
|
void |
setBucketName(String bucketName)
The bucket name containing the object.
|
void |
setExpectedBucketOwner(String expectedBucketOwner)
Set the account id of the expected bucket owner.
|
void |
setKey(String key)
Sets the key under which the object to be downloaded is stored.
|
void |
setMatchingETagConstraints(List<String> eTagList)
Sets the optional list of ETag constraints that when present must
include a match for the object's current ETag in order for this
request to be executed.
|
void |
setModifiedSinceConstraint(Date date)
Sets the optional modified constraint that restricts this request
to executing only if the object has been modified after the
specified date.
|
void |
setNonmatchingETagConstraints(List<String> eTagList)
Sets the optional list of ETag constraints that when present must
not include a match for the object's current ETag in order for this
request to be executed.
|
void |
setPartNumber(Integer partNumber)
Sets the optional part number that indicates the part to be downloaded in a multipart object.
|
void |
setProgressListener(ProgressListener progressListener)
Deprecated.
|
void |
setRange(long start)
Sets the optional inclusive start range within the desired object that the
rest of which will be downloaded by this request.
|
void |
setRange(long start,
long end)
Sets the optional inclusive byte range within the desired object that
will be downloaded by this request.
|
void |
setRequesterPays(boolean isRequesterPays)
Used for downloading an Amazon S3 Object from a Requester Pays Bucket.
|
void |
setResponseHeaders(ResponseHeaderOverrides responseHeaders)
Sets the headers to be overridden in the service response.
|
void |
setS3ObjectId(S3ObjectId s3ObjectId)
Sets the S3 object id for this request.
|
void |
setSSECustomerKey(SSECustomerKey sseKey)
Sets the optional customer-provided server-side encryption key to use to
decrypt this object.
|
void |
setUnmodifiedSinceConstraint(Date date)
Sets the optional unmodified constraint that restricts this request
to executing only if the object has not been modified after
the specified date.
|
void |
setVersionId(String versionId)
Sets the optional version ID specifying which version of the object to
download.
|
GetObjectRequest |
withBucketName(String bucketName)
The bucket name containing the object.
|
GetObjectRequest |
withExpectedBucketOwner(String expectedBucketOwner)
Set the account id of the expected bucket owner.
|
GetObjectRequest |
withKey(String key)
Sets the key under which the object to be downloaded is stored.
|
GetObjectRequest |
withMatchingETagConstraint(String eTag)
Sets a single ETag constraint to this request.
|
GetObjectRequest |
withModifiedSinceConstraint(Date date)
Sets the optional modified constraint that restricts this request
to executing only if the object has been modified after the
specified date.
|
GetObjectRequest |
withNonmatchingETagConstraint(String eTag)
Sets a single ETag constraint to this request.
|
GetObjectRequest |
withPartNumber(Integer partNumber)
Sets the optional part number that indicates the part to be downloaded in a multipart object.
|
GetObjectRequest |
withProgressListener(ProgressListener progressListener)
Deprecated.
|
GetObjectRequest |
withRange(long start)
Sets the optional inclusive start range within the desired object that the
rest of which will be downloaded by this request.
|
GetObjectRequest |
withRange(long start,
long end)
Sets the optional inclusive byte range within the desired object that
will be downloaded by this request.
|
GetObjectRequest |
withRequesterPays(boolean isRequesterPays)
Used for conducting this operation from a Requester Pays Bucket.
|
GetObjectRequest |
withResponseHeaders(ResponseHeaderOverrides responseHeaders)
Sets the headers to be overridden in the service response and returns
this object, for method chaining.
|
GetObjectRequest |
withS3ObjectId(S3ObjectId s3ObjectId)
Fluent API to set the S3 object id for this request.
|
GetObjectRequest |
withSSECustomerKey(SSECustomerKey sseKey)
Sets the optional customer-provided server-side encryption key to use to
decrypt this object, and returns the updated GetObjectRequest so that
additional method calls may be chained together.
|
GetObjectRequest |
withUnmodifiedSinceConstraint(Date date)
Sets the optional unmodified constraint that restricts this request
to executing only if the object has not been modified after
the specified date.
|
GetObjectRequest |
withVersionId(String versionId)
Sets the optional version ID specifying which version of the object to
download and returns this object, enabling additional method calls to be
chained together.
|
addHandlerContext, clone, getCloneRoot, getCloneSource, getCustomQueryParameters, getCustomRequestHeaders, getGeneralProgressListener, getHandlerContext, getReadLimit, getRequestClientOptions, getRequestCredentials, getRequestCredentialsProvider, getRequestMetricCollector, getSdkClientExecutionTimeout, getSdkRequestTimeout, putCustomQueryParameter, putCustomRequestHeader, setGeneralProgressListener, setRequestCredentials, setRequestCredentialsProvider, setRequestMetricCollector, setSdkClientExecutionTimeout, setSdkRequestTimeout, withGeneralProgressListener, withRequestCredentialsProvider, withRequestMetricCollector, withSdkClientExecutionTimeout, withSdkRequestTimeout
public GetObjectRequest(String bucketName, String key)
GetObjectRequest
with all the required parameters.
When using this action with an access point, you must direct requests to the access point hostname. The access point hostname takes the form AccessPointName-AccountId.s3-accesspoint.Region.amazonaws.com. When using this action with an access point through the Amazon Web Services SDKs, you provide the access point ARN in place of the bucket name. For more information about access point ARNs, see Using access points in the Amazon S3 User Guide.
When you use this action with Amazon S3 on Outposts, you must direct requests to the S3 on Outposts hostname. The
S3 on Outposts hostname takes the form
AccessPointName-AccountId.outpostID.s3-outposts.Region.amazonaws.com
.
When you use this action using S3 on Outposts through the Amazon Web Services SDKs, you provide the Outposts
access point ARN in place of the bucket name. For more information about S3 on Outposts ARNs, see What is S3 on Outposts in the
Amazon S3 User Guide.
bucketName
- The name of the bucket, or access point ARN, containing the desired object.
When using this action with an access point, you must direct requests to the access point hostname. The access point hostname takes the form AccessPointName-AccountId.s3-accesspoint.Region.amazonaws.com. When using this action with an access point through the Amazon Web Services SDKs, you provide the access point ARN in place of the bucket name. For more information about access point ARNs, see Using access points in the Amazon S3 User Guide.
When you use this action with Amazon S3 on Outposts, you must direct requests to the S3 on Outposts
hostname. The S3 on Outposts hostname takes the form
AccessPointName-AccountId.outpostID.s3-outposts.Region.amazonaws.com
.
When you use this action using S3 on Outposts through the Amazon Web Services SDKs, you provide the Outposts
access point ARN in place of the bucket name. For more information about S3 on Outposts ARNs, see What is S3 on Outposts
in the Amazon S3 User Guide.
key
- The key in the specified bucket under which the object is
stored.GetObjectRequest(String, String, String)
,
GetObjectRequest(String, String, boolean)
public GetObjectRequest(String bucketName, String key, String versionId)
GetObjectRequest
with all the required parameters.
When using this action with an access point, you must direct requests to the access point hostname. The access point hostname takes the form AccessPointName-AccountId.s3-accesspoint.Region.amazonaws.com. When using this action with an access point through the Amazon Web Services SDKs, you provide the access point ARN in place of the bucket name. For more information about access point ARNs, see Using access points in the Amazon S3 User Guide.
When you use this action with Amazon S3 on Outposts, you must direct requests to the S3 on Outposts hostname. The
S3 on Outposts hostname takes the form
AccessPointName-AccountId.outpostID.s3-outposts.Region.amazonaws.com
.
When you use this action using S3 on Outposts through the Amazon Web Services SDKs, you provide the Outposts
access point ARN in place of the bucket name. For more information about S3 on Outposts ARNs, see What is S3 on Outposts in the
Amazon S3 User Guide.
bucketName
- The name of the bucket, or access point ARN, containing the desired object.
When using this action with an access point, you must direct requests to the access point hostname. The access point hostname takes the form AccessPointName-AccountId.s3-accesspoint.Region.amazonaws.com. When using this action with an access point through the Amazon Web Services SDKs, you provide the access point ARN in place of the bucket name. For more information about access point ARNs, see Using access points in the Amazon S3 User Guide.
When you use this action with Amazon S3 on Outposts, you must direct requests to the S3 on Outposts
hostname. The S3 on Outposts hostname takes the form
AccessPointName-AccountId.outpostID.s3-outposts.Region.amazonaws.com
.
When you use this action using S3 on Outposts through the Amazon Web Services SDKs, you provide the Outposts
access point ARN in place of the bucket name. For more information about S3 on Outposts ARNs, see What is S3 on Outposts
in the Amazon S3 User Guide.
key
- The key in the specified bucket under which the object is
stored.versionId
- The Amazon S3 version ID specifying a specific version of the
object to download.GetObjectRequest(String, String)
,
GetObjectRequest(String, String, boolean)
public GetObjectRequest(S3ObjectId s3ObjectId)
public GetObjectRequest(String bucketName, String key, boolean isRequesterPays)
GetObjectRequest
with all the required
parameters.
When using this action with an access point, you must direct requests to the access point hostname. The access point hostname takes the form AccessPointName-AccountId.s3-accesspoint.Region.amazonaws.com. When using this action with an access point through the Amazon Web Services SDKs, you provide the access point ARN in place of the bucket name. For more information about access point ARNs, see Using access points in the Amazon S3 User Guide.
When you use this action with Amazon S3 on Outposts, you must direct requests to the S3 on Outposts hostname. The
S3 on Outposts hostname takes the form
AccessPointName-AccountId.outpostID.s3-outposts.Region.amazonaws.com
.
When you use this action using S3 on Outposts through the Amazon Web Services SDKs, you provide the Outposts
access point ARN in place of the bucket name. For more information about S3 on Outposts ARNs, see What is S3 on Outposts in the
Amazon S3 User Guide.
bucketName
- The name of the bucket, or access point ARN, containing the desired object.
When using this action with an access point, you must direct requests to the access point hostname. The access point hostname takes the form AccessPointName-AccountId.s3-accesspoint.Region.amazonaws.com. When using this action with an access point through the Amazon Web Services SDKs, you provide the access point ARN in place of the bucket name. For more information about access point ARNs, see Using access points in the Amazon S3 User Guide.
When you use this action with Amazon S3 on Outposts, you must direct requests to the S3 on Outposts
hostname. The S3 on Outposts hostname takes the form
AccessPointName-AccountId.outpostID.s3-outposts.Region.amazonaws.com
.
When you use this action using S3 on Outposts through the Amazon Web Services SDKs, you provide the Outposts
access point ARN in place of the bucket name. For more information about S3 on Outposts ARNs, see What is S3 on Outposts
in the Amazon S3 User Guide.
key
- The key in the specified bucket under which the object is
stored.isRequesterPays
- If enabled, the requester is charged for downloading the data
from Requester Pays Buckets.GetObjectRequest(String, String)
,
GetObjectRequest(String, String, String)
public String getExpectedBucketOwner()
ExpectedBucketOwnerRequest
403 (Access Denied)
error.getExpectedBucketOwner
in interface ExpectedBucketOwnerRequest
public GetObjectRequest withExpectedBucketOwner(String expectedBucketOwner)
ExpectedBucketOwnerRequest
403 (Access Denied)
error.withExpectedBucketOwner
in interface ExpectedBucketOwnerRequest
public void setExpectedBucketOwner(String expectedBucketOwner)
ExpectedBucketOwnerRequest
403 (Access Denied)
error.setExpectedBucketOwner
in interface ExpectedBucketOwnerRequest
public String getBucketName()
The bucket name containing the object.
When using this action with an access point, you must direct requests to the access point hostname. The access point hostname takes the form AccessPointName-AccountId.s3-accesspoint.Region.amazonaws.com. When using this action with an access point through the Amazon Web Services SDKs, you provide the access point ARN in place of the bucket name. For more information about access point ARNs, see Using access points in the Amazon S3 User Guide.
When you use this action with Amazon S3 on Outposts, you must direct requests to the S3 on Outposts hostname. The
S3 on Outposts hostname takes the form
AccessPointName-AccountId.outpostID.s3-outposts.Region.amazonaws.com
.
When you use this action using S3 on Outposts through the Amazon Web Services SDKs, you provide the Outposts
access point ARN in place of the bucket name. For more information about S3 on Outposts ARNs, see What is S3 on Outposts in the
Amazon S3 User Guide.
When using this action with an access point, you must direct requests to the access point hostname. The access point hostname takes the form AccessPointName-AccountId.s3-accesspoint.Region.amazonaws.com. When using this action with an access point through the Amazon Web Services SDKs, you provide the access point ARN in place of the bucket name. For more information about access point ARNs, see Using access points in the Amazon S3 User Guide.
When you use this action with Amazon S3 on Outposts, you must direct requests to the S3 on Outposts
hostname. The S3 on Outposts hostname takes the form
AccessPointName-AccountId.outpostID.s3-outposts.Region.amazonaws.com
.
When you use this action using S3 on Outposts through the Amazon Web Services SDKs, you provide the Outposts
access point ARN in place of the bucket name. For more information about S3 on Outposts ARNs, see What is S3 on Outposts
in the Amazon S3 User Guide.
setBucketName(String)
,
withBucketName(String)
public void setBucketName(String bucketName)
The bucket name containing the object.
When using this action with an access point, you must direct requests to the access point hostname. The access point hostname takes the form AccessPointName-AccountId.s3-accesspoint.Region.amazonaws.com. When using this action with an access point through the Amazon Web Services SDKs, you provide the access point ARN in place of the bucket name. For more information about access point ARNs, see Using access points in the Amazon S3 User Guide.
When you use this action with Amazon S3 on Outposts, you must direct requests to the S3 on Outposts hostname. The
S3 on Outposts hostname takes the form
AccessPointName-AccountId.outpostID.s3-outposts.Region.amazonaws.com
.
When you use this action using S3 on Outposts through the Amazon Web Services SDKs, you provide the Outposts
access point ARN in place of the bucket name. For more information about S3 on Outposts ARNs, see What is S3 on Outposts in the
Amazon S3 User Guide.
bucketName
- The bucket name containing the object.
When using this action with an access point, you must direct requests to the access point hostname. The access point hostname takes the form AccessPointName-AccountId.s3-accesspoint.Region.amazonaws.com. When using this action with an access point through the Amazon Web Services SDKs, you provide the access point ARN in place of the bucket name. For more information about access point ARNs, see Using access points in the Amazon S3 User Guide.
When you use this action with Amazon S3 on Outposts, you must direct requests to the S3 on Outposts
hostname. The S3 on Outposts hostname takes the form
AccessPointName-AccountId.outpostID.s3-outposts.Region.amazonaws.com
.
When you use this action using S3 on Outposts through the Amazon Web Services SDKs, you provide the Outposts
access point ARN in place of the bucket name. For more information about S3 on Outposts ARNs, see What is S3 on Outposts
in the Amazon S3 User Guide.
getBucketName()
,
withBucketName(String)
public GetObjectRequest withBucketName(String bucketName)
The bucket name containing the object.
When using this action with an access point, you must direct requests to the access point hostname. The access point hostname takes the form AccessPointName-AccountId.s3-accesspoint.Region.amazonaws.com. When using this action with an access point through the Amazon Web Services SDKs, you provide the access point ARN in place of the bucket name. For more information about access point ARNs, see Using access points in the Amazon S3 User Guide.
When you use this action with Amazon S3 on Outposts, you must direct requests to the S3 on Outposts hostname. The
S3 on Outposts hostname takes the form
AccessPointName-AccountId.outpostID.s3-outposts.Region.amazonaws.com
.
When you use this action using S3 on Outposts through the Amazon Web Services SDKs, you provide the Outposts
access point ARN in place of the bucket name. For more information about S3 on Outposts ARNs, see What is S3 on Outposts in the
Amazon S3 User Guide.
bucketName
- The bucket name containing the object.
When using this action with an access point, you must direct requests to the access point hostname. The access point hostname takes the form AccessPointName-AccountId.s3-accesspoint.Region.amazonaws.com. When using this action with an access point through the Amazon Web Services SDKs, you provide the access point ARN in place of the bucket name. For more information about access point ARNs, see Using access points in the Amazon S3 User Guide.
When you use this action with Amazon S3 on Outposts, you must direct requests to the S3 on Outposts
hostname. The S3 on Outposts hostname takes the form
AccessPointName-AccountId.outpostID.s3-outposts.Region.amazonaws.com
.
When you use this action using S3 on Outposts through the Amazon Web Services SDKs, you provide the Outposts
access point ARN in place of the bucket name. For more information about S3 on Outposts ARNs, see What is S3 on Outposts
in the Amazon S3 User Guide.
GetObjectRequest
, enabling additional method
calls to be chained together.getBucketName()
,
setBucketName(String)
public String getKey()
setKey(String)
,
withKey(String)
public void setKey(String key)
key
- The key under which the object to be downloaded is stored.getKey()
,
withKey(String)
public GetObjectRequest withKey(String key)
GetObjectRequest
, enabling additional method
calls to be chained together.key
- The key under which the object to be downloaded is stored.GetObjectRequest
, enabling additional method
calls to be chained together.getKey()
,
setKey(String)
public String getVersionId()
Gets the optional version ID specifying which version of the object to download. If not specified, the most recent version will be downloaded.
Objects created before versioning was enabled or when versioning is
suspended are given the default null
version ID (see
Constants.NULL_VERSION_ID
). Note that the
null
version ID is a valid version ID and is not the
same as not having a version ID.
For more information about enabling versioning for a bucket, see
AmazonS3.setBucketVersioningConfiguration(SetBucketVersioningConfigurationRequest)
.
setVersionId(String)
,
withVersionId(String)
public void setVersionId(String versionId)
Objects created before versioning was enabled or when versioning is
suspended will be given the default null
version ID (see
Constants.NULL_VERSION_ID
). Note that the
null
version ID is a valid version ID and is not the
same as not having a version ID.
For more information about enabling versioning for a bucket, see
AmazonS3.setBucketVersioningConfiguration(SetBucketVersioningConfigurationRequest)
.
versionId
- The optional version ID specifying which version of the object
to download.getVersionId()
,
withVersionId(String)
public GetObjectRequest withVersionId(String versionId)
Sets the optional version ID specifying which version of the object to download and returns this object, enabling additional method calls to be chained together. If not specified, the most recent version will be downloaded.
Objects created before versioning was enabled or when versioning is
suspended will be given the default or null
version ID (see
Constants.NULL_VERSION_ID
). Note that the
null
version ID is a valid version ID and is not the
same as not having a version ID.
For more information about enabling versioning for a bucket, see
AmazonS3.setBucketVersioningConfiguration(SetBucketVersioningConfigurationRequest)
.
versionId
- The optional version ID specifying which version of the object
to download.getVersionId()
,
setVersionId(String)
public long[] getRange()
Gets the optional inclusive byte range within the desired object that will be downloaded by this request.
The range is returned as
a two element array, containing the start and end index of the byte range.
If no byte range has been specified, the entire object is downloaded and
this method returns null
.
null
if no range has been specified,
and the whole object is
to be downloaded.setRange(long, long)
,
withRange(long, long)
public void setRange(long start, long end)
Sets the optional inclusive byte range within the desired object that will be downloaded by this request.
The first byte in an object has position 0; as an example, the first ten bytes of an object can be downloaded by specifying a range of 0 to 9.
If no byte range is specified, this request downloads the entire object from Amazon S3.
start
- The start of the inclusive byte range to download.end
- The end of the inclusive byte range to download.getRange()
,
withRange(long, long)
public void setRange(long start)
Sets the optional inclusive start range within the desired object that the rest of which will be downloaded by this request.
The first byte in an object has position 0; as an example, the object is of 10 bytes in length, the last 4 bytes can be downloaded by specifying the start range as 6.
If no byte range is specified, this request downloads the entire object from Amazon S3.
start
- The start of the inclusive byte range to download.setRange(long, long)
,
withRange(long)
public GetObjectRequest withRange(long start, long end)
Sets the optional inclusive byte range within the desired object that
will be downloaded by this request.
Returns this GetObjectRequest
, enabling additional method
calls to be chained together.
The first byte in an object has position 0; as an example, the first ten bytes of an object can be downloaded by specifying a range of 0 to 9.
If no byte range is specified, this request downloads the entire object from Amazon S3.
start
- The start of the inclusive byte range to download.end
- The end of the inclusive byte range to download.GetObjectRequest
, enabling additional method
calls to be chained together.getRange()
,
setRange(long, long)
public GetObjectRequest withRange(long start)
Sets the optional inclusive start range within the desired object that the rest of which will be downloaded by this request.
Returns thisGetObjectRequest
, enabling additional method
calls to be chained together.
The first byte in an object has position 0; as an example, the object is of 10 bytes in length, the last 4 bytes can be downloaded by specifying the start range as 6.
If no byte range is specified, this request downloads the entire object from Amazon S3.
start
- The start of the inclusive byte range to download.GetObjectRequest
, enabling additional method
calls to be chained together.withRange(long, long)
,
setRange(long)
public List<String> getMatchingETagConstraints()
setMatchingETagConstraints(List)
,
withMatchingETagConstraint(String)
public void setMatchingETagConstraints(List<String> eTagList)
eTagList
- The optional list of ETag constraints that must include a
match for the object's current ETag in order for this request
to be executed.getMatchingETagConstraints()
,
withMatchingETagConstraint(String)
public GetObjectRequest withMatchingETagConstraint(String eTag)
GetObjectRequest
, enabling additional method
calls to be chained together.
Multiple ETag constraints can be added to a request, but one must match the object's current ETag in order for this request to be executed. If none of the ETag constraints added to this request match the object's current ETag, this request will not be executed by Amazon S3.
eTag
- The matching ETag constraint to add to this request.GetObjectRequest
, enabling additional method
calls to be chained together.getMatchingETagConstraints()
,
setMatchingETagConstraints(List)
public List<String> getNonmatchingETagConstraints()
setNonmatchingETagConstraints(List)
,
withNonmatchingETagConstraint(String)
public void setNonmatchingETagConstraints(List<String> eTagList)
eTagList
- The list of ETag constraints that, when present, must not
include a match for the object's current ETag in order for
this request to be executed.getNonmatchingETagConstraints()
,
withNonmatchingETagConstraint(String)
public GetObjectRequest withNonmatchingETagConstraint(String eTag)
GetObjectRequest
, enabling additional method
calls to be chained together.
Multiple ETag constraints can be added to a request, but all ETag constraints must not match the object's current ETag in order for this request to be executed. If any entry in the non-matching ETag constraint list matches the object's current ETag, this request will not be executed by Amazon S3.
eTag
- The non-matching ETag constraint to add to this request.GetObjectRequest
, enabling additional method
calls to be chained together.getNonmatchingETagConstraints()
,
setNonmatchingETagConstraints(List)
public Date getUnmodifiedSinceConstraint()
setUnmodifiedSinceConstraint(Date)
,
withUnmodifiedSinceConstraint(Date)
public void setUnmodifiedSinceConstraint(Date date)
Note that Amazon S3 will ignore any dates occurring in the future.
date
- The unmodified constraint that restricts this request to
executing only if the object has not been
modified after this date.getUnmodifiedSinceConstraint()
,
withUnmodifiedSinceConstraint(Date)
public GetObjectRequest withUnmodifiedSinceConstraint(Date date)
GetObjectRequest
, enabling additional method
calls to be chained together.
Note that Amazon S3 will ignore any dates occurring in the future.
date
- The unmodified constraint that restricts this request to
executing only if the object has not been
modified after this date.GetObjectRequest
, enabling additional method
calls to be chained together.getUnmodifiedSinceConstraint()
,
setUnmodifiedSinceConstraint(Date)
public Date getModifiedSinceConstraint()
setModifiedSinceConstraint(Date)
,
withModifiedSinceConstraint(Date)
public void setModifiedSinceConstraint(Date date)
Note that Amazon S3 will ignore any dates occurring in the future.
date
- The modified constraint that restricts this request to
executing only if the object has been modified
after the specified date.getModifiedSinceConstraint()
,
withModifiedSinceConstraint(Date)
public GetObjectRequest withModifiedSinceConstraint(Date date)
GetObjectRequest
, enabling additional method
calls to be chained together.
Note that Amazon S3 will ignore any dates occurring in the future.
date
- The modified constraint that restricts this request to
executing only if the object has been modified
after the specified date.GetObjectRequest
, enabling additional method
calls to be chained together.getModifiedSinceConstraint()
,
setModifiedSinceConstraint(Date)
public ResponseHeaderOverrides getResponseHeaders()
public void setResponseHeaders(ResponseHeaderOverrides responseHeaders)
responseHeaders
- The headers to be overridden in the service response.public GetObjectRequest withResponseHeaders(ResponseHeaderOverrides responseHeaders)
responseHeaders
- The headers to be overridden in the service response.GetObjectRequest
for method chaining.@Deprecated public void setProgressListener(ProgressListener progressListener)
AmazonWebServiceRequest.setGeneralProgressListener(ProgressListener)
instead.progressListener
- The legacy progress listener that is used exclusively for Amazon S3 client.@Deprecated public ProgressListener getProgressListener()
AmazonWebServiceRequest.getGeneralProgressListener()
instead.@Deprecated public GetObjectRequest withProgressListener(ProgressListener progressListener)
AmazonWebServiceRequest.withGeneralProgressListener(ProgressListener)
instead.progressListener
- The legacy progress listener that is used exclusively for Amazon S3 client.public boolean isRequesterPays()
If a bucket is enabled for Requester Pays, then any attempt to read an object from it without Requester Pays enabled will result in a 403 error and the bucket owner will be charged for the request.
Enabling Requester Pays disables the ability to have anonymous access to this bucket
public void setRequesterPays(boolean isRequesterPays)
If a bucket is enabled for Requester Pays, then any attempt to read an object from it without Requester Pays enabled will result in a 403 error and the bucket owner will be charged for the request.
Enabling Requester Pays disables the ability to have anonymous access to this bucket
isRequesterPays
- Enable Requester Pays option for the operation.public GetObjectRequest withRequesterPays(boolean isRequesterPays)
If a bucket is enabled for Requester Pays, then any attempt to upload or download an object from it without Requester Pays enabled will result in a 403 error and the bucket owner will be charged for the request.
Enabling Requester Pays disables the ability to have anonymous access to this bucket.
isRequesterPays
- Enable Requester Pays option for the operation.public SSECustomerKey getSSECustomerKey()
SSECustomerKeyProvider
getSSECustomerKey
in interface SSECustomerKeyProvider
public void setSSECustomerKey(SSECustomerKey sseKey)
sseKey
- The optional customer-provided server-side encryption key to
use to decrypt this object.public GetObjectRequest withSSECustomerKey(SSECustomerKey sseKey)
sseKey
- The optional customer-provided server-side encryption key to
use to decrypt this object.public Integer getPartNumber()
Returns the optional part number that indicates the part to be downloaded in a multipart object.
setPartNumber(Integer)
,
withPartNumber(Integer)
public void setPartNumber(Integer partNumber)
Sets the optional part number that indicates the part to be downloaded in a multipart object.
The valid range for part number is 1 - 10000 inclusive. Part numbers are 1 based. If an object has 1 part, partNumber=1 would be the correct not 0. For partNumber < 1, an AmazonS3Exception is thrown with response code 400 bad request. For partNumber larger than actual part count, an AmazonS3Exception is thrown with response code 416 Request Range Not Satisfiable.
partNumber
- The part number representing a part in a multipart object.getPartNumber()
,
withPartNumber(Integer)
public GetObjectRequest withPartNumber(Integer partNumber)
Sets the optional part number that indicates the part to be downloaded in a multipart object.
The valid range for part number is 1 - 10000 inclusive. Part numbers are 1 based. If an object has 1 part, partNumber=1 would be the correct not 0. For partNumber < 1, an AmazonS3Exception is thrown with response code 400 bad request. For partNumber larger than actual part count, an AmazonS3Exception is thrown with response code 416 Request Range Not Satisfiable.
partNumber
- The part number representing a part in a multipart object.GetObjectRequest
, enabling additional method
calls to be chained together.getPartNumber()
,
setPartNumber(Integer)
public S3ObjectId getS3ObjectId()
public void setS3ObjectId(S3ObjectId s3ObjectId)
public GetObjectRequest withS3ObjectId(S3ObjectId s3ObjectId)