@ThreadSafe public class AmazonS3Client extends AmazonWebServiceClient implements AmazonS3
Provides the client for accessing the Amazon S3 web service.
Amazon S3 provides storage for the Internet, and is designed to make web-scale computing easier for developers.
The Amazon S3 Java Client provides a simple interface that can be used to store and retrieve any amount of data, at any time, from anywhere on the web. It gives any developer access to the same highly scalable, reliable, secure, fast, inexpensive infrastructure that Amazon uses to run its own global network of web sites. The service aims to maximize benefits of scale and to pass those benefits on to developers.
For more information about Amazon S3, please see http://aws.amazon.com/s3
Modifier and Type | Field and Description |
---|---|
protected AWSCredentialsProvider |
awsCredentialsProvider
Provider for Amazon Web Services credentials.
|
protected static com.ibm.cloud.objectstorage.services.s3.AmazonS3ClientConfigurationFactory |
configFactory |
protected S3ErrorResponseHandler |
errorResponseHandler
Responsible for handling error responses from all S3 service calls.
|
static String |
OAUTH_SIGNER |
static String |
S3_SERVICE_NAME |
client, clientConfiguration, endpoint, isEndpointOverridden, LOGGING_AWS_REQUEST_METRIC, requestHandler2s, timeOffset
ENDPOINT_PREFIX
Constructor and Description |
---|
AmazonS3Client()
Deprecated.
|
AmazonS3Client(AWSCredentials awsCredentials)
Deprecated.
|
AmazonS3Client(AWSCredentials awsCredentials,
ClientConfiguration clientConfiguration)
|
AmazonS3Client(AWSCredentialsProvider credentialsProvider)
Deprecated.
|
AmazonS3Client(AWSCredentialsProvider credentialsProvider,
ClientConfiguration clientConfiguration)
|
AmazonS3Client(AWSCredentialsProvider credentialsProvider,
ClientConfiguration clientConfiguration,
RequestMetricCollector requestMetricCollector)
|
AmazonS3Client(ClientConfiguration clientConfiguration)
Deprecated.
|
Modifier and Type | Method and Description |
---|---|
void |
abortMultipartUpload(AbortMultipartUploadRequest abortMultipartUploadRequest)
Aborts a multipart upload.
|
protected Request<CreateBucketRequest> |
addIAMHeaders(Request<CreateBucketRequest> request,
CreateBucketRequest createBucketRequest)
Add IAM specific headers based on the credentials set & any optional
parameters added to the CreateBucketRequest object
|
void |
addLegalHold(AddLegalHoldRequest addLegalHoldRequest)
Adds a legal hold to the specified object in the specified bucket.
|
void |
addLegalHold(String bucketName,
String key,
String legalHoldId)
Adds a legal hold to the specified object in the specified bucket.
|
static AmazonS3ClientBuilder |
builder() |
void |
changeObjectStorageClass(String bucketName,
String key,
StorageClass newStorageClass)
/**
|
CompleteMultipartUploadResult |
completeMultipartUpload(CompleteMultipartUploadRequest completeMultipartUploadRequest)
Completes a multipart upload by assembling previously uploaded parts.
|
CopyObjectResult |
copyObject(CopyObjectRequest copyObjectRequest)
Copies a source object to a new destination in Amazon S3.
|
CopyObjectResult |
copyObject(String sourceBucketName,
String sourceKey,
String destinationBucketName,
String destinationKey)
Copies a source object to a new destination in Amazon S3.
|
CopyPartResult |
copyPart(CopyPartRequest copyPartRequest)
Copies a source object to a part of a multipart upload.
|
Bucket |
createBucket(CreateBucketRequest createBucketRequest)
Creates a new S3 bucket.
|
Bucket |
createBucket(String bucketName)
Creates a new S3 bucket.
|
Bucket |
createBucket(String bucketName,
Region region)
Deprecated.
|
Bucket |
createBucket(String bucketName,
String region)
Deprecated.
|
protected <X extends AmazonWebServiceRequest> |
createRequest(String bucketName,
String key,
X originalRequest,
HttpMethodName httpMethod)
Creates and initializes a new request object for the specified S3
resource.
|
protected <X extends AmazonWebServiceRequest> |
createRequest(String bucketName,
String key,
X originalRequest,
HttpMethodName httpMethod,
URI endpoint) |
protected Signer |
createSigner(Request<?> request,
String bucketName,
String key)
Returns a "complete" S3 specific signer, taking into the S3 bucket, key,
and the current S3 client configuration into account.
|
protected Signer |
createSigner(Request<?> request,
String bucketName,
String key,
boolean isAdditionalHeadRequestToFindRegion)
Returns a "complete" S3 specific signer, taking into the S3 bucket, key,
and the current S3 client configuration into account.
|
protected SignerProvider |
createSignerProvider(Signer signer) |
void |
deleteBucket(DeleteBucketRequest deleteBucketRequest)
Deletes the specified bucket.
|
void |
deleteBucket(String bucketName)
Deletes the specified bucket.
|
void |
deleteBucketCrossOriginConfiguration(DeleteBucketCrossOriginConfigurationRequest deleteBucketCrossOriginConfigurationRequest)
Delete the cross origin configuration for the specified bucket.
|
void |
deleteBucketCrossOriginConfiguration(String bucketName)
Delete the cross origin configuration for the specified bucket.
|
void |
deleteBucketLifecycleConfiguration(DeleteBucketLifecycleConfigurationRequest deleteBucketLifecycleConfigurationRequest)
Removes the lifecycle configuration for the bucket specified.
|
void |
deleteBucketLifecycleConfiguration(String bucketName)
Removes the lifecycle configuration for the bucket specified.
|
void |
deleteBucketReplicationConfiguration(DeleteBucketReplicationConfigurationRequest deleteBucketReplicationConfigurationRequest)
Deletes the replication configuration for the given Amazon S3 bucket.
|
void |
deleteBucketReplicationConfiguration(String bucketName)
Deletes the replication configuration for the given Amazon S3 bucket.
|
void |
deleteBucketWebsiteConfiguration(DeleteBucketWebsiteConfigurationRequest deleteBucketWebsiteConfigurationRequest)
This operation removes the website configuration for a bucket.
|
void |
deleteBucketWebsiteConfiguration(String bucketName)
This operation removes the website configuration for a bucket.
|
void |
deleteLegalHold(DeleteLegalHoldRequest deleteLegalHoldRequest)
Deletes a legal hold for the specified object in the specified bucket.
|
void |
deleteLegalHold(String bucketName,
String key,
String legalHoldId)
Deletes a legal hold for the specified object in the specified bucket.
|
void |
deleteObject(DeleteObjectRequest deleteObjectRequest)
Deletes the specified object in the specified bucket.
|
void |
deleteObject(String bucketName,
String key)
Deletes the specified object in the specified bucket.
|
DeleteObjectsResult |
deleteObjects(DeleteObjectsRequest deleteObjectsRequest)
Deletes multiple objects in a single bucket from S3.
|
com.ibm.cloud.objectstorage.services.s3.model.DeleteObjectTaggingResult |
deleteObjectTagging(com.ibm.cloud.objectstorage.services.s3.model.DeleteObjectTaggingRequest deleteObjectTaggingRequest)
Removes the entire tag set from the specified object.
|
DeletePublicAccessBlockResult |
deletePublicAccessBlock(DeletePublicAccessBlockRequest deletePublicAccessBlockRequest)
Removes the Public Access Block configuration for an Amazon S3 bucket.
|
void |
deleteVersion(DeleteVersionRequest deleteVersionRequest)
Deletes a specific version of an object in the specified bucket.
|
void |
deleteVersion(String bucketName,
String key,
String versionId)
Deletes a specific version of the specified object in the specified
bucket.
|
boolean |
doesBucketExist(String bucketName)
Checks if the specified bucket exists.
|
boolean |
doesBucketExistV2(String bucketName)
Checks if the specified bucket exists.
|
boolean |
doesObjectExist(String bucketName,
String objectName) |
PresignedUrlDownloadResult |
download(PresignedUrlDownloadRequest presignedUrlDownloadRequest)
Gets the object stored in Amazon S3 using a presigned url.
|
void |
download(PresignedUrlDownloadRequest presignedUrlDownloadRequest,
File destinationFile)
Gets the object stored in Amazon S3 using a presigned url.
|
void |
extendObjectRetention(ExtendObjectRetentionRequest extendObjectRetentionRequest)
Extends the retention period of a protected object in a protected vault.
|
void |
extendObjectRetention(String bucketName,
String key,
Long additionalRetentionPeriod,
Long extendRetentionFromCurrentTime,
Date newRetentionExpirationDate,
Long newRetentionPeriod)
Extends the retention period of a protected object in a protected vault.
|
URL |
generatePresignedUrl(GeneratePresignedUrlRequest req)
Returns a pre-signed URL for accessing an Amazon S3 resource.
|
URL |
generatePresignedUrl(String bucketName,
String key,
Date expiration)
Returns a pre-signed URL for accessing an Amazon S3 resource.
|
URL |
generatePresignedUrl(String bucketName,
String key,
Date expiration,
HttpMethod method)
Returns a pre-signed URL for accessing an Amazon S3 resource.
|
AccessControlList |
getBucketAcl(GetBucketAclRequest getBucketAclRequest)
Gets the
AccessControlList (ACL) for the specified Amazon S3
bucket. |
AccessControlList |
getBucketAcl(String bucketName)
Gets the
AccessControlList (ACL) for the specified Amazon S3 bucket. |
BucketCrossOriginConfiguration |
getBucketCrossOriginConfiguration(GetBucketCrossOriginConfigurationRequest getBucketCrossOriginConfigurationRequest)
Gets the cross origin configuration for the specified bucket, or null if
no configuration has been established.
|
BucketCrossOriginConfiguration |
getBucketCrossOriginConfiguration(String bucketName)
Gets the cross origin configuration for the specified bucket, or null if
the specified bucket does not exist, or an empty list if no
configuration has been established.
|
FASPConnectionInfo |
getBucketFaspConnectionInfo(GetBucketFaspConnectionInfoRequest getBucketFaspConnectionInfoRequest)
Gets the FASP Connection Info for a particular bucket.
|
FASPConnectionInfo |
getBucketFaspConnectionInfo(String bucketName)
Gets the FASP Connection Info for a particular bucket.
|
BucketLifecycleConfiguration |
getBucketLifecycleConfiguration(GetBucketLifecycleConfigurationRequest getBucketLifecycleConfigurationRequest)
Gets the lifecycle configuration for the specified bucket, or null if
the specified bucket does not exist or if no configuration has been established.
|
BucketLifecycleConfiguration |
getBucketLifecycleConfiguration(String bucketName)
Gets the lifecycle configuration for the specified bucket, or null if
the specified bucket does not exist or if no configuration has been established.
|
BucketProtectionConfiguration |
getBucketProtection(String bucketName)
Gets the protection configuration for the specified bucket.
|
BucketProtectionConfiguration |
getBucketProtectionConfiguration(GetBucketProtectionConfigurationRequest getBucketProtectionRequest) |
BucketReplicationConfiguration |
getBucketReplicationConfiguration(GetBucketReplicationConfigurationRequest getBucketReplicationConfigurationRequest)
Retrieves the replication configuration for the given Amazon S3 bucket.
|
BucketReplicationConfiguration |
getBucketReplicationConfiguration(String bucketName)
Retrieves the replication configuration for the given Amazon S3 bucket.
|
BucketVersioningConfiguration |
getBucketVersioningConfiguration(GetBucketVersioningConfigurationRequest getBucketVersioningConfigurationRequest)
Returns the versioning configuration for the specified bucket.
|
BucketVersioningConfiguration |
getBucketVersioningConfiguration(String bucketName)
Returns the versioning configuration for the specified bucket.
|
BucketWebsiteConfiguration |
getBucketWebsiteConfiguration(GetBucketWebsiteConfigurationRequest getBucketWebsiteConfigurationRequest)
Returns the website configuration for the specified bucket.
|
BucketWebsiteConfiguration |
getBucketWebsiteConfiguration(String bucketName)
Returns the website configuration for the specified bucket.
|
S3ResponseMetadata |
getCachedResponseMetadata(AmazonWebServiceRequest request)
Gets additional metadata for a previously executed successful request.
|
S3Object |
getObject(GetObjectRequest getObjectRequest)
Retrieves objects from Amazon S3.
|
ObjectMetadata |
getObject(GetObjectRequest getObjectRequest,
File destinationFile)
Retrieves objects from Amazon S3.
|
S3Object |
getObject(String bucketName,
String key)
Retrieves objects from Amazon S3.
|
AccessControlList |
getObjectAcl(GetObjectAclRequest getObjectAclRequest)
Gets the
AccessControlList (ACL) for the specified object in Amazon S3. |
AccessControlList |
getObjectAcl(String bucketName,
String key)
Gets the
AccessControlList (ACL) for the specified object in Amazon S3. |
AccessControlList |
getObjectAcl(String bucketName,
String key,
String versionId)
Gets the
AccessControlList (ACL) for the specified object
with the specified version in Amazon S3. |
String |
getObjectAsString(String bucketName,
String key)
Retrieves and decodes the contents of an S3 object to a String.
|
GetObjectLegalHoldResult |
getObjectLegalHold(GetObjectLegalHoldRequest getObjectLegalHoldRequest)
Gets an object's current Legal Hold status.
|
GetObjectLockConfigurationResult |
getObjectLockConfiguration(GetObjectLockConfigurationRequest getObjectLockConfigurationRequest)
Gets the Object Lock configuration for a bucket.
|
ObjectMetadata |
getObjectMetadata(GetObjectMetadataRequest getObjectMetadataRequest)
The HEAD action retrieves metadata from an object without returning the object itself.
|
ObjectMetadata |
getObjectMetadata(String bucketName,
String key)
Gets the metadata for the specified Amazon S3 object without
actually fetching the object itself.
|
GetObjectRetentionResult |
getObjectRetention(GetObjectRetentionRequest getObjectRetentionRequest)
Retrieves an object's retention settings.
|
com.ibm.cloud.objectstorage.services.s3.model.GetObjectTaggingResult |
getObjectTagging(com.ibm.cloud.objectstorage.services.s3.model.GetObjectTaggingRequest getObjectTaggingRequest)
Returns the tags for the specified object.
|
GetPublicAccessBlockResult |
getPublicAccessBlock(GetPublicAccessBlockRequest getPublicAccessBlockRequest)
Retrieves the Public Access Block configuration for an Amazon S3 bucket.
|
Region |
getRegion()
Returns the region with which the client is configured.
|
String |
getRegionName()
Returns a string representation of the region with which this
client is configured
|
String |
getResourceUrl(String bucketName,
String key)
Returns the URL to the key in the bucket given, using the client's scheme
and endpoint.
|
Owner |
getS3AccountOwner()
Gets the current owner of the Amazon Web Services account
that the authenticated sender of the request is using.
|
Owner |
getS3AccountOwner(GetS3AccountOwnerRequest getS3AccountOwnerRequest)
Gets the current owner of the Amazon Web Services account
that the authenticated sender of the request is using.
|
URL |
getUrl(String bucketName,
String key)
Returns an URL for the object stored in the specified bucket and
key.
|
HeadBucketResult |
headBucket(HeadBucketRequest headBucketRequest)
This action is useful to determine if a bucket exists and you have permission to access it.
|
InitiateMultipartUploadResult |
initiateMultipartUpload(InitiateMultipartUploadRequest initiateMultipartUploadRequest)
Initiates a multipart upload and returns an InitiateMultipartUploadResult
which contains an upload ID.
|
List<Bucket> |
listBuckets()
Returns a list of all buckets owned by the authenticated sender of the request.
|
List<Bucket> |
listBuckets(ListBucketsRequest listBucketsRequest)
Returns a list of all buckets owned by the authenticated sender of the request.
|
ListBucketsExtendedResponse |
listBucketsExtended()
Returns a list of all Cloud Object Storage (COS) S3 buckets that the
authenticated sender of the request owns.
|
ListBucketsExtendedResponse |
listBucketsExtended(ListBucketsExtendedRequest listBucketsExtendedRequest)
Returns a list of all Cloud Object Storage (COS) S3 buckets that the
authenticated sender of the request owns.
|
ListLegalHoldsResult |
listLegalHolds(ListLegalHoldsRequest listLegalHoldsRequest)
Returns a list of legal holds for the specified key in the specified bucket.
|
ListLegalHoldsResult |
listLegalHolds(String bucketName,
String key)
Returns a list of legal holds for the specified key in the specified bucket.
|
MultipartUploadListing |
listMultipartUploads(ListMultipartUploadsRequest listMultipartUploadsRequest)
Lists in-progress multipart uploads.
|
ObjectListing |
listNextBatchOfObjects(ListNextBatchOfObjectsRequest listNextBatchOfObjectsRequest)
Provides an easy way to continue a truncated object listing and retrieve
the next page of results.
|
ObjectListing |
listNextBatchOfObjects(ObjectListing previousObjectListing)
Provides an easy way to continue a truncated object listing and retrieve
the next page of results.
|
VersionListing |
listNextBatchOfVersions(com.ibm.cloud.objectstorage.services.s3.model.ListNextBatchOfVersionsRequest listNextBatchOfVersionsRequest)
Provides an easy way to continue a truncated
VersionListing and retrieve
the next page of results. |
VersionListing |
listNextBatchOfVersions(VersionListing previousVersionListing)
Provides an easy way to continue a truncated
VersionListing and retrieve
the next page of results. |
ObjectListing |
listObjects(ListObjectsRequest listObjectsRequest)
Returns a list of summary information about the objects in the specified
bucket.
|
ObjectListing |
listObjects(String bucketName)
Returns a list of summary information about the objects in the specified
buckets.
|
ObjectListing |
listObjects(String bucketName,
String prefix)
Returns a list of summary information about the objects in the specified
bucket.
|
ListObjectsV2Result |
listObjectsV2(ListObjectsV2Request listObjectsV2Request) |
ListObjectsV2Result |
listObjectsV2(String bucketName) |
ListObjectsV2Result |
listObjectsV2(String bucketName,
String prefix) |
PartListing |
listParts(ListPartsRequest listPartsRequest)
Lists the parts that have been uploaded for a specific multipart upload.
|
VersionListing |
listVersions(com.ibm.cloud.objectstorage.services.s3.model.ListVersionsRequest listVersionsRequest)
Returns a list of summary information about the versions in the specified
bucket.
|
VersionListing |
listVersions(String bucketName,
String prefix)
Returns a list of summary information about the versions in the specified
bucket.
|
VersionListing |
listVersions(String bucketName,
String prefix,
String keyMarker,
String versionIdMarker,
String delimiter,
Integer maxKeys)
Returns a list of summary information about the versions in the specified
bucket.
|
protected InitiateMultipartUploadRequest |
newInitiateMultipartUploadRequest(UploadObjectRequest req)
Creates and returns a multi-part upload initiation request from the given upload-object
request.
|
protected static void |
populateRequesterPaysHeader(Request<?> request,
boolean isRequesterPays)
Populate the specified request with
Constants.REQUESTER_PAYS to header Headers.REQUESTER_PAYS_HEADER ,
if isRequesterPays is true. |
protected static void |
populateRequestMetadata(Request<?> request,
ObjectMetadata metadata)
Populates the specified request object with the appropriate headers from
the
ObjectMetadata object. |
protected <T> void |
presignRequest(Request<T> request,
HttpMethod methodName,
String bucketName,
String key,
Date expiration,
String subResource)
Pre-signs the specified request, using a signature query-string
parameter.
|
PutObjectResult |
putObject(PutObjectRequest putObjectRequest)
Uploads a new object to the specified Amazon S3 bucket.
|
PutObjectResult |
putObject(String bucketName,
String key,
File file)
Uploads the specified file to Amazon S3 under the specified bucket and
key name.
|
PutObjectResult |
putObject(String bucketName,
String key,
InputStream input,
ObjectMetadata metadata)
Uploads the specified input stream and object metadata to Amazon S3 under
the specified bucket and key name.
|
PutObjectResult |
putObject(String bucketName,
String key,
String content)
Encodes a String into the contents of an S3 object.
|
void |
restoreObject(RestoreObjectRequest restoreObjectRequest)
Restore an object, which was transitioned to Amazon Glacier from Amazon
S3 when it was expired, into Amazon S3 again.
|
void |
restoreObject(String bucketName,
String key,
int expirationInDays)
Restore an object, which was transitioned to Amazon Glacier from Amazon
S3 when it was expired, into Amazon S3 again.
|
void |
setBucketAcl(SetBucketAclRequest setBucketAclRequest)
Sets the
AccessControlList for the specified Amazon S3 bucket. |
void |
setBucketAcl(String bucketName,
AccessControlList acl)
Sets the
AccessControlList for the specified Amazon S3 bucket. |
void |
setBucketAcl(String bucketName,
AccessControlList acl,
RequestMetricCollector requestMetricCollector)
Same as
AmazonS3Client.setBucketAcl(String, AccessControlList)
but allows specifying a request metric collector. |
void |
setBucketAcl(String bucketName,
CannedAccessControlList cannedAcl)
Sets the
CannedAccessControlList for the specified Amazon S3 bucket using one of
the pre-configured CannedAccessControlLists . |
void |
setBucketAcl(String bucketName,
CannedAccessControlList cannedAcl,
RequestMetricCollector requestMetricCollector)
Same as
AmazonS3Client.setBucketAcl(String, CannedAccessControlList)
but allows specifying a request metric collector. |
void |
setBucketCrossOriginConfiguration(SetBucketCrossOriginConfigurationRequest setBucketCrossOriginConfigurationRequest)
Sets the cross origin configuration for the specified bucket.
|
void |
setBucketCrossOriginConfiguration(String bucketName,
BucketCrossOriginConfiguration bucketCrossOriginConfiguration)
Sets the cross origin configuration for the specified bucket.
|
void |
setBucketLifecycleConfiguration(SetBucketLifecycleConfigurationRequest setBucketLifecycleConfigurationRequest)
Sets the lifecycle configuration for the specified bucket.
|
void |
setBucketLifecycleConfiguration(String bucketName,
BucketLifecycleConfiguration bucketLifecycleConfiguration)
Sets the lifecycle configuration for the specified bucket.
|
void |
setBucketProtection(String bucketName,
BucketProtectionConfiguration protectionConfiguration) |
void |
setBucketProtectionConfiguration(SetBucketProtectionConfigurationRequest setBucketProtectionConfigurationRequest)
Set the protection configuration for the specified bucket.
|
void |
setBucketReplicationConfiguration(SetBucketReplicationConfigurationRequest setBucketReplicationConfigurationRequest)
Creates a replication configuration or replaces an existing one.
|
void |
setBucketReplicationConfiguration(String bucketName,
BucketReplicationConfiguration configuration)
Creates a replication configuration or replaces an existing one.
|
void |
setBucketVersioningConfiguration(SetBucketVersioningConfigurationRequest setBucketVersioningConfigurationRequest)
Sets the versioning configuration for the specified bucket.
|
void |
setBucketWebsiteConfiguration(SetBucketWebsiteConfigurationRequest setBucketWebsiteConfigurationRequest)
Sets the website configuration for the specified bucket.
|
void |
setBucketWebsiteConfiguration(String bucketName,
BucketWebsiteConfiguration configuration)
Sets the website configuration for the specified bucket.
|
void |
setEndpoint(String endpoint)
|
void |
setObjectAcl(SetObjectAclRequest setObjectAclRequest)
Sets the
AccessControlList for the specified Amazon S3 object
with an optional version ID. |
void |
setObjectAcl(String bucketName,
String key,
AccessControlList acl)
Sets the
AccessControlList for the specified object in Amazon S3. |
void |
setObjectAcl(String bucketName,
String key,
CannedAccessControlList acl)
Sets the
CannedAccessControlList for the specified object in
Amazon S3 using one
of the pre-configured CannedAccessControlLists . |
void |
setObjectAcl(String bucketName,
String key,
String versionId,
AccessControlList acl)
Sets the
CannedAccessControlList for the specified object
with the specified version in Amazon S3. |
void |
setObjectAcl(String bucketName,
String key,
String versionId,
AccessControlList acl,
RequestMetricCollector requestMetricCollector)
Same as
AmazonS3Client.setObjectAcl(String, String, String, AccessControlList)
but allows specifying a request metric collector. |
void |
setObjectAcl(String bucketName,
String key,
String versionId,
CannedAccessControlList acl)
Sets the
CannedAccessControlList for the specified object with the specified
version ID in Amazon S3 using one of the pre-configured
CannedAccessControlLists . |
void |
setObjectAcl(String bucketName,
String key,
String versionId,
CannedAccessControlList acl,
RequestMetricCollector requestMetricCollector)
Same as
AmazonS3Client.setObjectAcl(String, String, String, CannedAccessControlList)
but allows specifying a request metric collector. |
SetObjectLegalHoldResult |
setObjectLegalHold(SetObjectLegalHoldRequest setObjectLegalHoldRequest)
Applies a Legal Hold configuration to the specified object.
|
SetObjectLockConfigurationResult |
setObjectLockConfiguration(SetObjectLockConfigurationRequest setObjectLockConfigurationRequest)
Places an Object Lock configuration on the specified bucket.
|
void |
setObjectRedirectLocation(String bucketName,
String key,
String newRedirectLocation)
Changes the Amazon S3 redirect location for a specific object.
|
SetObjectRetentionResult |
setObjectRetention(SetObjectRetentionRequest setObjectRetentionRequest)
Places an Object Retention configuration on an object.
|
com.ibm.cloud.objectstorage.services.s3.model.SetObjectTaggingResult |
setObjectTagging(com.ibm.cloud.objectstorage.services.s3.model.SetObjectTaggingRequest setObjectTaggingRequest)
Set the tags for the specified object.
|
SetPublicAccessBlockResult |
setPublicAccessBlock(SetPublicAccessBlockRequest setPublicAccessBlockRequest)
Creates or modifies the Public Access Block configuration for an Amazon S3 bucket.
|
void |
setRegion(Region region)
Deprecated.
|
void |
setS3ClientOptions(S3ClientOptions clientOptions)
Override the default S3 client options for this client.
|
PresignedUrlUploadResult |
upload(PresignedUrlUploadRequest presignedUrlUploadRequest)
Uploads a new object into S3 using the given presigned url.
|
UploadPartResult |
uploadPart(UploadPartRequest uploadPartRequest)
Uploads a part in a multipart upload.
|
protected boolean |
useStrictHostNameVerification()
S3 uses wildcard certificates so we have to disable strict hostname verification when using
SSL.
|
AmazonS3Waiters |
waiters() |
addRequestHandler, addRequestHandler, beforeClientExecution, beforeMarshalling, calculateCRC32FromCompressedData, checkMutability, configureRegion, createExecutionContext, createExecutionContext, createExecutionContext, endClientExecution, endClientExecution, getClientConfiguration, getEndpointPrefix, getMonitoringListeners, getRequestMetricsCollector, getServiceAbbreviation, getServiceName, getServiceNameIntern, getSigner, getSignerByURI, getSignerOverride, getSignerProvider, getSignerRegionOverride, getTimeOffset, isEndpointOverridden, isProfilingEnabled, isRequestMetricsEnabled, makeImmutable, removeRequestHandler, removeRequestHandler, requestMetricCollector, setEndpointPrefix, setServiceNameIntern, setSignerRegionOverride, setTimeOffset, shutdown, withEndpoint, withRegion, withRegion, withTimeOffset
public static final String S3_SERVICE_NAME
public static final String OAUTH_SIGNER
protected static final com.ibm.cloud.objectstorage.services.s3.AmazonS3ClientConfigurationFactory configFactory
protected final AWSCredentialsProvider awsCredentialsProvider
protected final S3ErrorResponseHandler errorResponseHandler
@Deprecated public AmazonS3Client()
AmazonS3ClientBuilder.defaultClient()
If no credentials are found in the chain, this client will attempt to work in an anonymous mode where requests aren't signed. Only a subset of the Amazon S3 API will work with anonymous (i.e. unsigned) requests, but this can prove useful in some situations. For example:
Permission.Read
permission for the
GroupGrantee.AllUsers
group, anonymous clients can call
AmazonS3Client.listObjects(String)
to see what objects are stored in a bucket.Permission.Read
permission for the
GroupGrantee.AllUsers
group, anonymous clients can call
#String, String)
and
AmazonS3Client.getObjectMetadata(String, String)
to pull object content and
metadata.Permission.Write
permission for the
GroupGrantee.AllUsers
group, anonymous clients can upload objects
to the bucket.
You can force the client to operate in an anonymous mode, and skip the credentials
provider chain, by passing in null
for the credentials.
@Deprecated public AmazonS3Client(AWSCredentials awsCredentials)
AwsClientBuilder.withCredentials(AWSCredentialsProvider)
awsCredentials
- The Amazon Web Services credentials to use when making requests to Amazon S3
with this client.AmazonS3Client()
,
AmazonS3Client(AWSCredentials, ClientConfiguration)
@Deprecated public AmazonS3Client(AWSCredentials awsCredentials, ClientConfiguration clientConfiguration)
AwsClientBuilder.withCredentials(AWSCredentialsProvider)
and
AwsClientBuilder.withClientConfiguration(ClientConfiguration)
awsCredentials
- The Amazon Web Services credentials to use when making requests to Amazon S3
with this client.clientConfiguration
- The client configuration options controlling how this client
connects to Amazon S3 (e.g. proxy settings, retry counts, etc).AmazonS3Client()
,
AmazonS3Client(AWSCredentials)
@Deprecated public AmazonS3Client(AWSCredentialsProvider credentialsProvider)
AwsClientBuilder.withCredentials(AWSCredentialsProvider)
credentialsProvider
- The Amazon Web Services credentials provider which will provide credentials
to authenticate requests with Amazon Web Services services.@Deprecated public AmazonS3Client(AWSCredentialsProvider credentialsProvider, ClientConfiguration clientConfiguration)
AwsClientBuilder.withCredentials(AWSCredentialsProvider)
and
AwsClientBuilder.withClientConfiguration(ClientConfiguration)
credentialsProvider
- The Amazon Web Services credentials provider which will provide credentials
to authenticate requests with Amazon Web Services services.clientConfiguration
- The client configuration options controlling how this client
connects to Amazon S3 (e.g. proxy settings, retry counts, etc).@Deprecated public AmazonS3Client(AWSCredentialsProvider credentialsProvider, ClientConfiguration clientConfiguration, RequestMetricCollector requestMetricCollector)
AwsClientBuilder.withCredentials(AWSCredentialsProvider)
and
AwsClientBuilder.withClientConfiguration(ClientConfiguration)
and
AwsClientBuilder.withMetricsCollector(RequestMetricCollector)
credentialsProvider
- The Amazon Web Services credentials provider which will provide credentials
to authenticate requests with Amazon Web Services services.clientConfiguration
- The client configuration options controlling how this client
connects to Amazon S3 (e.g. proxy settings, retry counts, etc).requestMetricCollector
- request metric collector@Deprecated public AmazonS3Client(ClientConfiguration clientConfiguration)
AwsClientBuilder.withClientConfiguration(ClientConfiguration)
If no credentials are found in the chain, this client will attempt to work in an anonymous mode where requests aren't signed. Only a subset of the Amazon S3 API will work with anonymous (i.e. unsigned) requests, but this can prove useful in some situations. For example:
Permission.Read
permission for the
GroupGrantee.AllUsers
group, anonymous clients can call
AmazonS3Client.listObjects(String)
to see what objects are stored in a bucket.Permission.Read
permission for the
GroupGrantee.AllUsers
group, anonymous clients can call
AmazonS3Client.getObject(String, String)
and
AmazonS3Client.getObjectMetadata(String, String)
to pull object content and
metadata.Permission.Write
permission for the
GroupGrantee.AllUsers
group, anonymous clients can upload objects
to the bucket.
You can force the client to operate in an anonymous mode, and skip the
credentials provider chain, by passing in null
for the
credentials.
clientConfiguration
- The client configuration options controlling how this client
connects to Amazon S3 (e.g. proxy settings, retry counts, etc).AmazonS3Client(AWSCredentials)
,
AmazonS3Client(AWSCredentials, ClientConfiguration)
public static AmazonS3ClientBuilder builder()
@Deprecated public void setEndpoint(String endpoint)
AmazonWebServiceClient
This method is not threadsafe. Endpoints should be configured when the client is created and before any service requests are made. Changing it afterwards creates inevitable race conditions for any service requests in transit.
Callers can pass in just the endpoint (ex: "ec2.amazonaws.com") or a full
URL, including the protocol (ex: "https://ec2.amazonaws.com"). If the
protocol is not specified here, the default protocol from this client's
ClientConfiguration
will be used, which by default is HTTPS.
For more information on using AWS regions with the AWS SDK for Java, and a complete list of all available endpoints for all AWS services, see: https://docs.aws.amazon.com/sdk-for-java/v1/developer-guide/java-dg-region-selection.html#region-selection-choose-endpoint
setEndpoint
in interface AmazonS3
setEndpoint
in class AmazonWebServiceClient
endpoint
- The endpoint (ex: "ec2.amazonaws.com") or a full URL,
including the protocol (ex: "https://ec2.amazonaws.com") of
the region specific AWS endpoint this client will communicate
with.@Deprecated public void setRegion(Region region)
AwsClientBuilder.setRegion(String)
AmazonWebServiceClient
AmazonWebServiceClient.setEndpoint(String)
, sets the regional
endpoint for this client's service calls. Callers can use this method to control which AWS
region they want to work with.
This method is not threadsafe. A region should be configured when the client is created and before any service requests are made. Changing it afterwards creates inevitable race conditions for any service requests in transit or retrying.
By default, all service endpoints in all regions use the https protocol. To use http instead,
specify it in the ClientConfiguration
supplied at construction.
setRegion
in interface AmazonS3
setRegion
in class AmazonWebServiceClient
region
- The region this client will communicate with. See
Region.getRegion(com.ibm.cloud.objectstorage.regions.Regions)
for accessing a given
region.Region.getRegion(com.ibm.cloud.objectstorage.regions.Regions)
,
Region.createClient(Class, com.ibm.cloud.objectstorage.auth.AWSCredentialsProvider,
ClientConfiguration)
public void setS3ClientOptions(S3ClientOptions clientOptions)
Override the default S3 client options for this client. Also set the endpoint to s3-accelerate if such is specified in the S3 client options.
setS3ClientOptions
in interface AmazonS3
clientOptions
- The S3 client options to use.protected boolean useStrictHostNameVerification()
useStrictHostNameVerification
in class AmazonWebServiceClient
public VersionListing listNextBatchOfVersions(VersionListing previousVersionListing) throws SdkClientException, AmazonServiceException
AmazonS3
Provides an easy way to continue a truncated VersionListing
and retrieve
the next page of results.
Obtain the initial
VersionListing
from one of the listVersions
methods. If the result
is truncated (indicated when VersionListing.isTruncated()
returns true
),
pass the VersionListing
back into this method in order to retrieve the
next page of results. From there, continue using this method to
retrieve more results until the returned VersionListing
indicates that
it is not truncated.
For more information about enabling versioning for a bucket, see
AmazonS3.setBucketVersioningConfiguration(SetBucketVersioningConfigurationRequest)
.
listNextBatchOfVersions
in interface AmazonS3
previousVersionListing
- The previous truncated VersionListing
.
If a
non-truncated VersionListing
is passed in, an empty
VersionListing
is returned without ever contacting
Amazon S3.VersionListing
results, beginning immediately
after the last result in the specified previous VersionListing
.SdkClientException
- If any errors are encountered in the client while making the
request or handling the response.AmazonServiceException
- If any errors occurred in Amazon S3 while processing the
request.AmazonS3Client.listVersions(String, String)
,
AmazonS3Client.listVersions(ListVersionsRequest)
,
AmazonS3Client.listVersions(String, String, String, String, String, Integer)
,
AmazonS3Client.listNextBatchOfVersions(ListNextBatchOfVersionsRequest)
,
Amazon Web Services API Documentationpublic VersionListing listNextBatchOfVersions(com.ibm.cloud.objectstorage.services.s3.model.ListNextBatchOfVersionsRequest listNextBatchOfVersionsRequest)
AmazonS3
Provides an easy way to continue a truncated VersionListing
and retrieve
the next page of results.
Obtain the initial
VersionListing
from one of the listVersions
methods. If the result
is truncated (indicated when VersionListing.isTruncated()
returns true
),
pass the VersionListing
back into this method in order to retrieve the
next page of results. From there, continue using this method to
retrieve more results until the returned VersionListing
indicates that
it is not truncated.
For more information about enabling versioning for a bucket, see
AmazonS3.setBucketVersioningConfiguration(SetBucketVersioningConfigurationRequest)
.
listNextBatchOfVersions
in interface AmazonS3
listNextBatchOfVersionsRequest
- The request object for listing next batch of versions using the previous
truncated VersionListing
. If a
non-truncated VersionListing
is passed in by the request object, an empty
VersionListing
is returned without ever contacting
Amazon S3.VersionListing
results, beginning immediately
after the last result in the specified previous VersionListing
.AmazonS3Client.listVersions(String, String)
,
AmazonS3Client.listVersions(ListVersionsRequest)
,
AmazonS3Client.listVersions(String, String, String, String, String, Integer)
,
AmazonS3Client.listNextBatchOfVersions(VersionListing)
,
Amazon Web Services API Documentationpublic VersionListing listVersions(String bucketName, String prefix) throws SdkClientException, AmazonServiceException
AmazonS3
Returns a list of summary information about the versions in the specified bucket.
The returned version summaries are ordered first by key and then by version. Keys are sorted lexicographically (alphabetically) while versions are sorted from most recent to least recent. Both versions with data and delete markers are included in the results.
Because buckets can contain a virtually unlimited number of versions, the
complete results of a list query can be extremely large. To manage large
result sets, Amazon S3 uses pagination to split them into multiple
responses. Always check the
VersionListing.isTruncated()
method to determine if the
returned listing is complete or if additional calls are needed to get
more results. Callers are
encouraged to use
AmazonS3.listNextBatchOfVersions(VersionListing)
as an easy way
to get the next page of results.
For more information about enabling versioning for a bucket, see
AmazonS3.setBucketVersioningConfiguration(SetBucketVersioningConfigurationRequest)
.
listVersions
in interface AmazonS3
bucketName
- The name of the Amazon S3 bucket whose versions are to be
listed.prefix
- An optional parameter restricting the response to keys
beginning with the specified prefix. Use prefixes to
separate a bucket into different sets of keys,
similar to how a file system organizes files
into directories.SdkClientException
- If any errors are encountered in the client while making the
request or handling the response.AmazonServiceException
- If any errors occurred in Amazon S3 while processing the
request.AmazonS3Client.listVersions(ListVersionsRequest)
,
AmazonS3Client.listVersions(String, String, String, String, String, Integer)
,
Amazon Web Services API Documentationpublic VersionListing listVersions(String bucketName, String prefix, String keyMarker, String versionIdMarker, String delimiter, Integer maxKeys) throws SdkClientException, AmazonServiceException
AmazonS3
Returns a list of summary information about the versions in the specified bucket.
The returned version summaries are ordered first by key and then by version. Keys are sorted lexicographically (alphabetically) and versions are sorted from most recent to least recent. Versions with data and delete markers are included in the results.
Because buckets can contain a virtually unlimited number of versions, the
complete results of a list query can be extremely large. To manage large
result sets, Amazon S3 uses pagination to split them into multiple
responses. Always check the
VersionListing.isTruncated()
method to determine if the
returned listing is complete or if additional calls are needed
to get more results.
Callers are
encouraged to use
AmazonS3.listNextBatchOfVersions(VersionListing)
as an easy way
to get the next page of results.
The keyMarker
and versionIdMarker
parameters allow
callers to specify where to start the version listing.
The delimiter
parameter allows groups of keys that share a
delimiter-terminated prefix to be included
in the returned listing. This allows applications to organize and browse
their keys hierarchically, much like how a file system organizes
files into directories. These common prefixes can be retrieved
by calling the VersionListing.getCommonPrefixes()
method.
For example, consider a bucket that contains the following keys:
listVersions
with
a prefix
value of "foo/" and a delimiter
value of "/"
on this bucket, a VersionListing
is returned that contains:
To see deeper into the virtual hierarchy, make
another call to listVersions
setting the prefix parameter to any
interesting common prefix to list the individual versions under that
prefix.
For more information about enabling versioning for a bucket, see
AmazonS3.setBucketVersioningConfiguration(SetBucketVersioningConfigurationRequest)
.
listVersions
in interface AmazonS3
bucketName
- The name of the Amazon S3 bucket whose versions are to be
listed.prefix
- An optional parameter restricting the response to keys that
begin with the specified prefix. Use prefixes to
separate a bucket into different sets of keys,
similar to how a file system organizes files
into directories.keyMarker
- Optional parameter indicating where in the sorted list of all
versions in the specified bucket to begin returning results.
Results are always ordered first lexicographically (i.e.
alphabetically) and then from most recent version to least
recent version. If a keyMarker is used without a
versionIdMarker, results begin immediately after that key's
last version. When a keyMarker is used with a versionIdMarker,
results begin immediately after the version with the specified
key and version ID.
This enables pagination; to get the next page of results use
the next key marker and next version ID marker (from
VersionListing.getNextKeyMarker()
and
VersionListing.getNextVersionIdMarker()
) as the
markers for the next request to list versions, or use the
convenience method
AmazonS3.listNextBatchOfVersions(VersionListing)
versionIdMarker
- Optional parameter indicating where in the sorted list of all
versions in the specified bucket to begin returning results.
Results are always ordered first lexicographically (i.e.
alphabetically) and then from most recent version to least
recent version. A keyMarker must be specified when specifying
a versionIdMarker. Results begin immediately after the version
with the specified key and version ID.
This enables pagination; to get the next page of results use
the next key marker and next version ID marker (from
VersionListing.getNextKeyMarker()
and
VersionListing.getNextVersionIdMarker()
) as the
markers for the next request to list versions, or use the
convenience method
AmazonS3.listNextBatchOfVersions(VersionListing)
delimiter
- Optional parameter that causes keys that contain the same
string between the prefix and the first occurrence of the
delimiter to be rolled up into a single result element in the
VersionListing.getCommonPrefixes()
list. These
rolled-up keys are not returned elsewhere in the response. The
most commonly used delimiter is "/", which simulates a
hierarchical organization similar to a file system directory
structure.maxKeys
- Optional parameter indicating the maximum number of results to
include in the response. Amazon S3 might return fewer than
this, but will not return more. Even if maxKeys is not
specified, Amazon S3 will limit the number of results in the
response.SdkClientException
- If any errors are encountered in the client while making the
request or handling the response.AmazonServiceException
- If any errors occurred in Amazon S3 while processing the
request.AmazonS3Client.listVersions(String, String)
,
AmazonS3Client.listVersions(ListVersionsRequest)
,
AmazonS3Client.listNextBatchOfVersions(VersionListing)
,
Amazon Web Services API Documentationpublic VersionListing listVersions(com.ibm.cloud.objectstorage.services.s3.model.ListVersionsRequest listVersionsRequest) throws SdkClientException, AmazonServiceException
AmazonS3
Returns a list of summary information about the versions in the specified bucket.
The returned version summaries are ordered first by key and then by version. Keys are sorted lexicographically (alphabetically) and versions are sorted from most recent to least recent. Versions with data and delete markers are included in the results.
Because buckets can contain a virtually unlimited number of versions, the
complete results of a list query can be extremely large. To manage large
result sets, Amazon S3 uses pagination to split them into multiple
responses. Always check the
VersionListing.isTruncated()
method to determine if the
returned listing is complete or if additional calls are needed
to get more results.
Callers are
encouraged to use
AmazonS3.listNextBatchOfVersions(VersionListing)
as an easy way
to get the next page of results.
The keyMarker
and versionIdMarker
parameters allow
callers to specify where to start the version listing.
The delimiter
parameter allows groups of keys that share a
delimiter-terminated prefix to be included
in the returned listing. This allows applications to organize and browse
their keys hierarchically, much like how a file system organizes
files into directories. These common prefixes can be retrieved
by calling the VersionListing.getCommonPrefixes()
method.
For example, consider a bucket that contains the following keys:
listVersions
with
a prefix
value of "foo/" and a delimiter
value of "/"
on this bucket, a VersionListing
is returned that contains:
To see deeper into the virtual hierarchy, make
another call to listVersions
setting the prefix parameter to any
interesting common prefix to list the individual versions under that
prefix.
For more information about enabling versioning for a bucket, see
AmazonS3.setBucketVersioningConfiguration(SetBucketVersioningConfigurationRequest)
.
listVersions
in interface AmazonS3
listVersionsRequest
- The request object containing all options for listing the
versions in a specified bucket.SdkClientException
- If any errors are encountered in the client while making the
request or handling the response.AmazonServiceException
- If any errors occurred in Amazon S3 while processing the
request.AmazonS3Client.listVersions(String, String)
,
AmazonS3Client.listVersions(String, String, String, String, String, Integer)
,
AmazonS3Client.listNextBatchOfVersions(VersionListing)
,
Amazon Web Services API Documentationpublic ObjectListing listObjects(String bucketName) throws SdkClientException, AmazonServiceException
AmazonS3
Returns a list of summary information about the objects in the specified buckets. List results are always returned in lexicographic (alphabetical) order.
Because buckets can contain a virtually unlimited number of keys, the
complete results of a list query can be extremely large. To manage large
result sets, Amazon S3 uses pagination to split them into multiple
responses. Always check the
ObjectListing.isTruncated()
method to see if the returned
listing is complete or if additional calls are needed to get
more results. Alternatively, use the
AmazonS3Client.listNextBatchOfObjects(ObjectListing)
method as
an easy way to get the next page of object listings.
The total number of keys in a bucket doesn't substantially affect list performance.
listObjects
in interface AmazonS3
bucketName
- The name of the Amazon S3 bucket to list.SdkClientException
- If any errors are encountered in the client while making the
request or handling the response.AmazonServiceException
- If any errors occurred in Amazon S3 while processing the
request.AmazonS3Client.listObjects(String, String)
,
AmazonS3Client.listObjects(ListObjectsRequest)
,
Amazon Web Services API Documentationpublic ObjectListing listObjects(String bucketName, String prefix) throws SdkClientException, AmazonServiceException
AmazonS3
Returns a list of summary information about the objects in the specified bucket. Depending on request parameters, additional information is returned, such as common prefixes if a delimiter was specified. List results are always returned in lexicographic (alphabetical) order.
Because buckets can contain a virtually unlimited number of keys, the
complete results of a list query can be extremely large. To manage large
result sets, Amazon S3 uses pagination to split them into multiple
responses. Always check the
ObjectListing.isTruncated()
method to see if the returned
listing is complete or if additional calls are needed to get
more results. Alternatively, use the
AmazonS3Client.listNextBatchOfObjects(ObjectListing)
method as
an easy way to get the next page of object listings.
For example, consider a bucket that contains the following keys:
listObjects
with
a prefix
value of "foo/" and a delimiter
value of "/"
on this bucket, an ObjectListing
is returned that contains one key
("foo/boo") and one entry in the common prefixes list ("foo/bar/").
To see deeper into the virtual hierarchy, make another
call to listObjects
setting the prefix parameter to any interesting
common prefix to list the individual keys under that prefix.
The total number of keys in a bucket doesn't substantially affect list performance.
listObjects
in interface AmazonS3
bucketName
- The name of the Amazon S3 bucket to list.prefix
- An optional parameter restricting the response to keys
beginning with the specified prefix. Use prefixes to
separate a bucket into different sets of keys,
similar to how a file system organizes files
into directories.SdkClientException
- If any errors are encountered in the client while making the
request or handling the response.AmazonServiceException
- If any errors occurred in Amazon S3 while processing the
request.AmazonS3Client.listObjects(String)
,
AmazonS3Client.listObjects(ListObjectsRequest)
,
Amazon Web Services API Documentationpublic ObjectListing listObjects(ListObjectsRequest listObjectsRequest) throws SdkClientException, AmazonServiceException
AmazonS3
Returns a list of summary information about the objects in the specified bucket. Depending on the request parameters, additional information is returned, such as common prefixes if a delimiter was specified. List results are always returned in lexicographic (alphabetical) order.
Because buckets can contain a virtually unlimited number of keys, the
complete results of a list query can be extremely large. To manage large
result sets, Amazon S3 uses pagination to split them into multiple
responses. Always check the
ObjectListing.isTruncated()
method to see if the returned
listing is complete or if additional calls are needed to get
more results. Alternatively, use the
AmazonS3Client.listNextBatchOfObjects(ObjectListing)
method as
an easy way to get the next page of object listings.
Calling ListObjectsRequest.setDelimiter(String)
sets the delimiter, allowing groups of keys that share the
delimiter-terminated prefix to be included
in the returned listing. This allows applications to organize and browse
their keys hierarchically, similar to how a file system organizes files
into directories. These common prefixes can be retrieved
through the ObjectListing.getCommonPrefixes()
method.
For example, consider a bucket that contains the following keys:
listObjects
with
a prefix value of "foo/" and a delimiter value of "/"
on this bucket, an ObjectListing
is returned that contains one key
("foo/boo") and one entry in the common prefixes list ("foo/bar/").
To see deeper into the virtual hierarchy, make another
call to listObjects
setting the prefix parameter to any interesting
common prefix to list the individual keys under that prefix.
The total number of keys in a bucket doesn't substantially affect list performance.
listObjects
in interface AmazonS3
listObjectsRequest
- The request object containing all options for listing the
objects in a specified bucket.SdkClientException
- If any errors are encountered in the client while making the
request or handling the response.AmazonServiceException
- If any errors occurred in Amazon S3 while processing the
request.AmazonS3Client.listObjects(String)
,
AmazonS3Client.listObjects(String, String)
,
Amazon Web Services API Documentationpublic ListObjectsV2Result listObjectsV2(String bucketName) throws SdkClientException, AmazonServiceException
listObjectsV2
in interface AmazonS3
SdkClientException
AmazonServiceException
public ListObjectsV2Result listObjectsV2(String bucketName, String prefix) throws SdkClientException, AmazonServiceException
listObjectsV2
in interface AmazonS3
SdkClientException
AmazonServiceException
public ListObjectsV2Result listObjectsV2(ListObjectsV2Request listObjectsV2Request) throws SdkClientException, AmazonServiceException
listObjectsV2
in interface AmazonS3
SdkClientException
AmazonServiceException
public ObjectListing listNextBatchOfObjects(ObjectListing previousObjectListing) throws SdkClientException, AmazonServiceException
AmazonS3
Provides an easy way to continue a truncated object listing and retrieve the next page of results.
To continue the object listing and retrieve the next page of results,
call the initial ObjectListing
from one of the
listObjects
methods.
If truncated
(indicated when ObjectListing.isTruncated()
returns true
),
pass the ObjectListing
back into this method
in order to retrieve the
next page of results. Continue using this method to
retrieve more results until the returned ObjectListing
indicates that
it is not truncated.
listNextBatchOfObjects
in interface AmazonS3
previousObjectListing
- The previous truncated ObjectListing
.
If a
non-truncated ObjectListing
is passed in, an empty
ObjectListing
is returned without ever contacting
Amazon S3.ObjectListing
results, beginning immediately
after the last result in the specified previous ObjectListing
.SdkClientException
- If any errors are encountered in the client while making the
request or handling the response.AmazonServiceException
- If any errors occurred in Amazon S3 while processing the
request.AmazonS3Client.listObjects(String)
,
AmazonS3Client.listObjects(String, String)
,
AmazonS3Client.listObjects(ListObjectsRequest)
,
AmazonS3Client.listNextBatchOfObjects(ListNextBatchOfObjectsRequest)
,
Amazon Web Services API Documentationpublic ObjectListing listNextBatchOfObjects(ListNextBatchOfObjectsRequest listNextBatchOfObjectsRequest) throws SdkClientException, AmazonServiceException
AmazonS3
Provides an easy way to continue a truncated object listing and retrieve the next page of results.
To continue the object listing and retrieve the next page of results,
call the initial ObjectListing
from one of the
listObjects
methods.
If truncated
(indicated when ObjectListing.isTruncated()
returns true
),
pass the ObjectListing
back into this method
in order to retrieve the
next page of results. Continue using this method to
retrieve more results until the returned ObjectListing
indicates that
it is not truncated.
listNextBatchOfObjects
in interface AmazonS3
listNextBatchOfObjectsRequest
- The request object for listing next batch of objects using the previous
truncated ObjectListing
. If a
non-truncated ObjectListing
is passed in by the request object, an empty
ObjectListing
is returned without ever contacting
Amazon S3.ObjectListing
results, beginning immediately
after the last result in the specified previous ObjectListing
.SdkClientException
- If any errors are encountered in the client while making the
request or handling the response.AmazonServiceException
- If any errors occurred in Amazon S3 while processing the
request.AmazonS3Client.listObjects(String)
,
AmazonS3Client.listObjects(String, String)
,
AmazonS3Client.listObjects(ListObjectsRequest)
,
AmazonS3Client.listNextBatchOfObjects(ObjectListing)
,
Amazon Web Services API Documentationpublic Owner getS3AccountOwner() throws SdkClientException, AmazonServiceException
AmazonS3
Gets the current owner of the Amazon Web Services account that the authenticated sender of the request is using.
The caller must authenticate with a valid Amazon Web Services Access Key ID that is registered with Amazon Web Services.
This operation uses the AmazonS3.listBuckets()
operation internally, and therefore requires the
<s3:ListAllMyBuckets
(S3Actions.ListBuckets
) IAM permission.
getS3AccountOwner
in interface AmazonS3
SdkClientException
- If any errors are encountered in the client while making the
request or handling the response.AmazonServiceException
- If any errors occurred in Amazon S3 while processing the
request.AmazonS3.getS3AccountOwner(GetS3AccountOwnerRequest)
public Owner getS3AccountOwner(GetS3AccountOwnerRequest getS3AccountOwnerRequest) throws SdkClientException, AmazonServiceException
AmazonS3
Gets the current owner of the Amazon Web Services account that the authenticated sender of the request is using.
The caller must authenticate with a valid Amazon Web Services Access Key ID that is registered with Amazon Web Services.
This operation uses the AmazonS3.listBuckets()
operation internally, and therefore requires the
<s3:ListAllMyBuckets
(S3Actions.ListBuckets
) IAM permission.
getS3AccountOwner
in interface AmazonS3
getS3AccountOwnerRequest
- The request object for retrieving the S3 account owner.SdkClientException
- If any errors are encountered in the client while making the
request or handling the response.AmazonServiceException
- If any errors occurred in Amazon S3 while processing the
request.AmazonS3.getS3AccountOwner()
public List<Bucket> listBuckets(ListBucketsRequest listBucketsRequest) throws SdkClientException, AmazonServiceException
AmazonS3
Returns a list of all buckets owned by the authenticated sender of the request. To use this operation, you must
have the s3:ListAllMyBuckets
permission.
For information about Amazon S3 buckets, see Creating, configuring, and working with Amazon S3 buckets.
listBuckets
in interface AmazonS3
listBucketsRequest
- The request containing all of the options related to the listing
of buckets.SdkClientException
- If any errors are encountered in the client while making the
request or handling the response.AmazonServiceException
- If any errors occurred in Amazon S3 while processing the
request.AmazonS3.listBuckets()
,
Amazon Web Services API Documentationpublic List<Bucket> listBuckets() throws SdkClientException, AmazonServiceException
AmazonS3
Returns a list of all buckets owned by the authenticated sender of the request. To use this operation, you must
have the s3:ListAllMyBuckets
permission.
For information about Amazon S3 buckets, see Creating, configuring, and working with Amazon S3 buckets.
listBuckets
in interface AmazonS3
SdkClientException
- If any errors are encountered in the client while making the
request or handling the response.AmazonServiceException
- If any errors occurred in Amazon S3 while processing the
request.AmazonS3.listBuckets(ListBucketsRequest)
,
Amazon Web Services API Documentationpublic ListBucketsExtendedResponse listBucketsExtended() throws SdkClientException, AmazonServiceException
AmazonS3
Returns a list of all Cloud Object Storage (COS) S3 buckets that the authenticated sender of the request owns.
Users must authenticate with a valid credentials that are registered with COS. Anonymous requests cannot list buckets, and users cannot list buckets that they did not create.
listBucketsExtended
in interface AmazonS3
SdkClientException
- If any errors are encountered in the client while making the
request or handling the response.AmazonServiceException
- If any errors occurred in COS S3 while processing the
request.public ListBucketsExtendedResponse listBucketsExtended(ListBucketsExtendedRequest listBucketsExtendedRequest) throws SdkClientException, AmazonServiceException
AmazonS3
Returns a list of all Cloud Object Storage (COS) S3 buckets that the authenticated sender of the request owns.
Users must authenticate with a valid credentials that are registered with COS. Anonymous requests cannot list buckets, and users cannot list buckets that they did not create.
listBucketsExtended
in interface AmazonS3
SdkClientException
- If any errors are encountered in the client while making the
request or handling the response.AmazonServiceException
- If any errors occurred in COS S3 while processing the
request.public Bucket createBucket(String bucketName) throws SdkClientException, AmazonServiceException
AmazonS3
Creates a new S3 bucket. To create a bucket, you must register with Amazon S3 and have a valid Amazon Web Services Access Key ID to authenticate requests. Anonymous requests are never allowed to create buckets. By creating the bucket, you become the bucket owner.
Not every string is an acceptable bucket name. For information about bucket naming restrictions, see Bucket naming rules.
If you want to create an Amazon S3 on Outposts bucket, see Create Bucket.
By default, the bucket is created in the US East (N. Virginia) Region. You can optionally specify a Region in the request body. You might choose a Region to optimize latency, minimize costs, or address regulatory requirements. For example, if you reside in Europe, you will probably find it advantageous to create buckets in the Europe (Ireland) Region. For more information, see Accessing a bucket.
If you send your create bucket request to the s3.amazonaws.com
endpoint, the request goes to the
us-east-1 Region. Accordingly, the signature calculations in Signature Version 4 must use us-east-1 as the
Region, even if the location constraint in the request specifies another Region where the bucket is to be
created. If you create a bucket in a Region other than US East (N. Virginia), your application must be able to
handle 307 redirect. For more information, see Virtual hosting of buckets.
When creating a bucket using this operation, you can optionally specify the accounts or groups that should be granted specific permissions on the bucket. There are two ways to grant the appropriate permissions using the request headers.
Specify a canned ACL using the x-amz-acl
request header. Amazon S3 supports a set of predefined
ACLs, known as canned ACLs. Each canned ACL has a predefined set of grantees and permissions. For more
information, see Canned
ACL.
Specify access permissions explicitly using the x-amz-grant-read
, x-amz-grant-write
,
x-amz-grant-read-acp
, x-amz-grant-write-acp
, and x-amz-grant-full-control
headers. These headers map to the set of permissions Amazon S3 supports in an ACL. For more information, see Access control list (ACL) overview.
You specify each grantee as a type=value pair, where the type is one of the following:
id
– if the value specified is the canonical user ID of an Amazon Web Services account
uri
– if you are granting permissions to a predefined group
emailAddress
– if the value specified is the email address of an Amazon Web Services account
Using email addresses to specify a grantee is only supported in the following Amazon Web Services Regions:
US East (N. Virginia)
US West (N. California)
US West (Oregon)
Asia Pacific (Singapore)
Asia Pacific (Sydney)
Asia Pacific (Tokyo)
Europe (Ireland)
South America (São Paulo)
For a list of all the Amazon S3 supported Regions and endpoints, see Regions and Endpoints in the Amazon Web Services General Reference.
For example, the following x-amz-grant-read
header grants the Amazon Web Services accounts
identified by account IDs permissions to read object data and its metadata:
x-amz-grant-read: id="11112222333", id="444455556666"
You can use either a canned ACL or specify access permissions explicitly. You cannot do both.
Permissions
If your CreateBucket
request specifies ACL permissions and the ACL is public-read,
public-read-write, authenticated-read, or if you specify access permissions explicitly through any other ACL,
both s3:CreateBucket
and s3:PutBucketAcl
permissions are needed. If the ACL the
CreateBucket
request is private, only s3:CreateBucket
permission is needed.
If ObjectLockEnabledForBucket
is set to true in your CreateBucket
request,
s3:PutBucketObjectLockConfiguration
and s3:PutBucketVersioning
permissions are
required.
The following operations are related to CreateBucket
:
createBucket
in interface AmazonS3
bucketName
- The name of the bucket to create.
All buckets in Amazon S3 share a single namespace;
ensure the bucket is given a unique name.SdkClientException
- If any errors are encountered in the client while making the
request or handling the response.AmazonServiceException
- If any errors occurred in Amazon S3 while processing the
request.@Deprecated public Bucket createBucket(String bucketName, Region region) throws SdkClientException, AmazonServiceException
AmazonS3
Creates a new Amazon S3 bucket with the specified name in the specified Amazon S3 region.
Every object stored in Amazon S3 is contained within a bucket. Buckets partition the namespace of objects stored in Amazon S3 at the top level. Within a bucket, any name can be used for objects. However, bucket names must be unique across all of Amazon S3.
Bucket ownership is similar to the ownership of Internet domain names. Within Amazon S3, only a single user owns each bucket. Once a uniquely named bucket is created in Amazon S3, organize and name the objects within the bucket in any way. Ownership of the bucket is retained as long as the owner has an Amazon S3 account.
To conform with DNS requirements, the following constraints apply:
There are no limits to the number of objects that can be stored in a bucket. Performance does not vary based on the number of buckets used. Store all objects within a single bucket or organize them across several buckets.
Buckets cannot be nested; buckets cannot be created within other buckets.
Do not make bucket create or delete calls in the high availability code path of an application. Create or delete buckets in a separate initialization or setup routine that runs less often.
To create a bucket, authenticate with an account that has a valid Amazon Web Services Access Key ID and is registered with Amazon S3. Anonymous requests are never allowed to create buckets.
createBucket
in interface AmazonS3
bucketName
- The name of the bucket to create.region
- The Amazon S3 region in which to create the new bucket.SdkClientException
- If any errors are encountered in the client while making the
request or handling the response.AmazonServiceException
- If any errors occurred in Amazon S3 while processing the
request.Region
,
Amazon Web Services API Documentation@Deprecated public Bucket createBucket(String bucketName, String region) throws SdkClientException, AmazonServiceException
AmazonS3
Creates a new Amazon S3 bucket with the specified name in the specified
Amazon S3 region. This method is provided for non-standard cases;
use AmazonS3.createBucket(String, Region)
and pass in a Region
enumeration value in standard cases.
Every object stored in Amazon S3 is contained within a bucket. Buckets partition the namespace of objects stored in Amazon S3 at the top level. Within a bucket, any name can be used for objects. However, bucket names must be unique across all of Amazon S3.
Bucket ownership is similar to the ownership of Internet domain names. Within Amazon S3, only a single user owns each bucket. Once a uniquely named bucket is created in Amazon S3, organize and name the objects within the bucket in any way. Ownership of the bucket is retained as long as the owner has an Amazon S3 account.
To conform with DNS requirements, the following constraints apply:
There are no limits to the number of objects that can be stored in a bucket. Performance does not vary based on the number of buckets used. Store all objects within a single bucket or organize them across several buckets.
Buckets cannot be nested; buckets cannot be created within other buckets.
Do not make bucket create or delete calls in the high availability code path of an application. Create or delete buckets in a separate initialization or setup routine that runs less often.
To create a bucket, authenticate with an account that has a valid Amazon Web Services Access Key ID and is registered with Amazon S3. Anonymous requests are never allowed to create buckets.
createBucket
in interface AmazonS3
bucketName
- The name of the bucket to create.region
- The Amazon S3 region in which to create the new bucket.SdkClientException
- If any errors are encountered in the client while making the
request or handling the response.AmazonServiceException
- If any errors occurred in Amazon S3 while processing the
request.Region
,
Amazon Web Services API Documentationpublic Bucket createBucket(CreateBucketRequest createBucketRequest) throws SdkClientException, AmazonServiceException
AmazonS3
Creates a new S3 bucket. To create a bucket, you must register with Amazon S3 and have a valid Amazon Web Services Access Key ID to authenticate requests. Anonymous requests are never allowed to create buckets. By creating the bucket, you become the bucket owner.
Not every string is an acceptable bucket name. For information about bucket naming restrictions, see Bucket naming rules.
If you want to create an Amazon S3 on Outposts bucket, see Create Bucket.
By default, the bucket is created in the US East (N. Virginia) Region. You can optionally specify a Region in the request body. You might choose a Region to optimize latency, minimize costs, or address regulatory requirements. For example, if you reside in Europe, you will probably find it advantageous to create buckets in the Europe (Ireland) Region. For more information, see Accessing a bucket.
If you send your create bucket request to the s3.amazonaws.com
endpoint, the request goes to the
us-east-1 Region. Accordingly, the signature calculations in Signature Version 4 must use us-east-1 as the
Region, even if the location constraint in the request specifies another Region where the bucket is to be
created. If you create a bucket in a Region other than US East (N. Virginia), your application must be able to
handle 307 redirect. For more information, see Virtual hosting of buckets.
Access control lists (ACLs)
When creating a bucket using this operation, you can optionally configure the bucket ACL to specify the accounts or groups that should be granted specific permissions on the bucket.
If your CreateBucket request sets bucket owner enforced for S3 Object Ownership and specifies a bucket ACL that
provides access to an external Amazon Web Services account, your request fails with a 400
error and
returns the InvalidBucketAclWithObjectOwnership
error code. For more information, see Controlling object
ownership in the Amazon S3 User Guide.
There are two ways to grant the appropriate permissions using the request headers.
Specify a canned ACL using the x-amz-acl
request header. Amazon S3 supports a set of predefined
ACLs, known as canned ACLs. Each canned ACL has a predefined set of grantees and permissions. For more
information, see Canned
ACL.
Specify access permissions explicitly using the x-amz-grant-read
, x-amz-grant-write
,
x-amz-grant-read-acp
, x-amz-grant-write-acp
, and x-amz-grant-full-control
headers. These headers map to the set of permissions Amazon S3 supports in an ACL. For more information, see Access control list (ACL)
overview.
You specify each grantee as a type=value pair, where the type is one of the following:
id
– if the value specified is the canonical user ID of an Amazon Web Services account
uri
– if you are granting permissions to a predefined group
emailAddress
– if the value specified is the email address of an Amazon Web Services account
Using email addresses to specify a grantee is only supported in the following Amazon Web Services Regions:
US East (N. Virginia)
US West (N. California)
US West (Oregon)
Asia Pacific (Singapore)
Asia Pacific (Sydney)
Asia Pacific (Tokyo)
Europe (Ireland)
South America (São Paulo)
For a list of all the Amazon S3 supported Regions and endpoints, see Regions and Endpoints in the Amazon Web Services General Reference.
For example, the following x-amz-grant-read
header grants the Amazon Web Services accounts
identified by account IDs permissions to read object data and its metadata:
x-amz-grant-read: id="11112222333", id="444455556666"
You can use either a canned ACL or specify access permissions explicitly. You cannot do both.
Permissions
In addition to s3:CreateBucket
, the following permissions are required when your CreateBucket
includes specific headers:
ACLs - If your CreateBucket
request specifies ACL permissions and the ACL is public-read,
public-read-write, authenticated-read, or if you specify access permissions explicitly through any other ACL,
both s3:CreateBucket
and s3:PutBucketAcl
permissions are needed. If the ACL the
CreateBucket
request is private or doesn't specify any ACLs, only s3:CreateBucket
permission is needed.
Object Lock - If ObjectLockEnabledForBucket
is set to true in your CreateBucket
request, s3:PutBucketObjectLockConfiguration
and s3:PutBucketVersioning
permissions are
required.
S3 Object Ownership - If your CreateBucket request includes the the x-amz-object-ownership
header, s3:PutBucketOwnershipControls
permission is required.
The following operations are related to CreateBucket
:
createBucket
in interface AmazonS3
createBucketRequest
- The request object containing all options for creating an Amazon S3
bucket.SdkClientException
- If any errors are encountered in the client while making the
request or handling the response.AmazonServiceException
- If any errors occurred in Amazon S3 while processing the
request.public AccessControlList getObjectAcl(String bucketName, String key) throws SdkClientException, AmazonServiceException
AmazonS3
Gets the AccessControlList
(ACL) for the specified object in Amazon S3.
Each bucket and object in Amazon S3 has an ACL that defines its access control policy. When a request is made, Amazon S3 authenticates the request using its standard authentication procedure and then checks the ACL to verify the sender was granted access to the bucket or object. If the sender is approved, the request proceeds. Otherwise, Amazon S3 returns an error.
getObjectAcl
in interface AmazonS3
bucketName
- The name of the bucket containing the object whose ACL is
being retrieved.key
- The key of the object within the specified bucket whose ACL is
being retrieved.AccessControlList
for the specified Amazon S3 object.SdkClientException
- If any errors are encountered in the client while making the
request or handling the response.AmazonServiceException
- If any errors occurred in Amazon S3 while processing the
request.AmazonS3.getObjectAcl(String, String, String)
,
Amazon Web Services API Documentationpublic AccessControlList getObjectAcl(String bucketName, String key, String versionId) throws SdkClientException, AmazonServiceException
AmazonS3
Gets the AccessControlList
(ACL) for the specified object
with the specified version in Amazon S3.
Each version of an object has its own associated
ACL.
Each bucket and object in Amazon S3 has an ACL that defines its access control policy. When a request is made, Amazon S3 authenticates the request using its standard authentication procedure and then checks the ACL to verify the sender was granted access to the bucket or object. If the sender is approved, the request proceeds. Otherwise, Amazon S3 returns an error.
For more information about enabling versioning for a bucket, see
AmazonS3.setBucketVersioningConfiguration(SetBucketVersioningConfigurationRequest)
.
getObjectAcl
in interface AmazonS3
bucketName
- The name of the bucket containing the object whose ACL is
being retrieved.key
- The key of the object within the specified bucket whose ACL is
being retrieved.versionId
- The version ID of the object version whose ACL is being
retrieved.AccessControlList
for the specified Amazon S3 object.SdkClientException
- If any errors are encountered in the client while making the
request or handling the response.AmazonServiceException
- If any errors occurred in Amazon S3 while processing the
request.AmazonS3.getObjectAcl(String, String)
,
Amazon Web Services API Documentationpublic AccessControlList getObjectAcl(GetObjectAclRequest getObjectAclRequest)
AmazonS3
Gets the AccessControlList
(ACL) for the specified object in Amazon S3.
Each bucket and object in Amazon S3 has an ACL that defines its access control policy. When a request is made, Amazon S3 authenticates the request using its standard authentication procedure and then checks the ACL to verify the sender was granted access to the bucket or object. If the sender is approved, the request proceeds. Otherwise, Amazon S3 returns an error.
getObjectAcl
in interface AmazonS3
getObjectAclRequest
- the request object containing all the information needed for retrieving
the object ACL.AccessControlList
for the specified Amazon S3 object.AmazonS3.getObjectAcl(String, String, String)
,
Amazon Web Services API Documentationpublic void setObjectAcl(String bucketName, String key, AccessControlList acl) throws SdkClientException, AmazonServiceException
AmazonS3
Sets the AccessControlList
for the specified object in Amazon S3.
Each bucket and object in Amazon S3 has an ACL that defines its access control policy. When a request is made, Amazon S3 authenticates the request using its standard authentication procedure and then checks the ACL to verify the sender was granted access to the bucket or object. If the sender is approved, the request proceeds. Otherwise, Amazon S3 returns an error.
When constructing a custom AccessControlList
,
callers typically retrieve
the existing AccessControlList
for an object (
AmazonS3Client.getObjectAcl(String, String)
), modify it as
necessary, and then use this method to upload the new ACL.
setObjectAcl
in interface AmazonS3
bucketName
- The name of the bucket containing the object whose ACL is
being set.key
- The key of the object within the specified bucket whose ACL is
being set.acl
- The new AccessControlList
for the specified object.SdkClientException
- If any errors are encountered in the client while making the
request or handling the response.AmazonServiceException
- If any errors occurred in Amazon S3 while processing the
request.AmazonS3.setObjectAcl(String, String, CannedAccessControlList)
,
AmazonS3.setObjectAcl(String, String, String, AccessControlList)
,
AmazonS3.setObjectAcl(String, String, String, CannedAccessControlList)
,
Amazon Web Services API Documentationpublic void setObjectAcl(String bucketName, String key, CannedAccessControlList acl) throws SdkClientException, AmazonServiceException
AmazonS3
Sets the CannedAccessControlList
for the specified object in
Amazon S3 using one
of the pre-configured CannedAccessControlLists
.
A CannedAccessControlList
provides a quick way to configure an object or bucket with commonly used
access control policies.
Each bucket and object in Amazon S3 has an ACL that defines its access control policy. When a request is made, Amazon S3 authenticates the request using its standard authentication procedure and then checks the ACL to verify the sender was granted access to the bucket or object. If the sender is approved, the request proceeds. Otherwise, Amazon S3 returns an error.
setObjectAcl
in interface AmazonS3
bucketName
- The name of the bucket containing the object whose ACL is
being set.key
- The key of the object within the specified bucket whose ACL is
being set.acl
- The new pre-configured CannedAccessControlList
for the
specified object.SdkClientException
- If any errors are encountered in the client while making the
request or handling the response.AmazonServiceException
- If any errors occurred in Amazon S3 while processing the
request.AmazonS3.setObjectAcl(String, String, AccessControlList)
,
AmazonS3.setObjectAcl(String, String, String, AccessControlList)
,
AmazonS3.setObjectAcl(String, String, String, CannedAccessControlList)
,
Amazon Web Services API Documentationpublic void setObjectAcl(String bucketName, String key, String versionId, AccessControlList acl) throws SdkClientException, AmazonServiceException
AmazonS3
Sets the CannedAccessControlList
for the specified object
with the specified version in Amazon S3.
Each version of an object has its own associated
ACL.
Each bucket and object in Amazon S3 has an ACL that defines its access control policy. When a request is made, Amazon S3 authenticates the request using its standard authentication procedure and then checks the ACL to verify the sender was granted access to the bucket or object. If the sender is approved, the request proceeds. Otherwise, Amazon S3 returns an error.
When constructing a custom AccessControlList
, callers typically retrieve
the existing AccessControlList
for an object (
AmazonS3Client.getObjectAcl(String, String)
), modify it as
necessary, and then use this method to upload the new ACL.
For more information about enabling versioning for a bucket, see
AmazonS3.setBucketVersioningConfiguration(SetBucketVersioningConfigurationRequest)
.
setObjectAcl
in interface AmazonS3
bucketName
- The name of the bucket containing the object whose ACL is
being set.key
- The key of the object within the specified bucket whose ACL is
being set.versionId
- The version ID of the object version whose ACL is being set.acl
- The new AccessControlList
for the specified object.SdkClientException
- If any errors are encountered in the client while making the
request or handling the response.AmazonServiceException
- If any errors occurred in Amazon S3 while processing the
request.AmazonS3.setObjectAcl(String, String, AccessControlList)
,
AmazonS3.setObjectAcl(String, String, CannedAccessControlList)
,
AmazonS3.setObjectAcl(String, String, String, CannedAccessControlList)
,
Amazon Web Services API Documentationpublic void setObjectAcl(String bucketName, String key, String versionId, AccessControlList acl, RequestMetricCollector requestMetricCollector) throws SdkClientException, AmazonServiceException
AmazonS3Client.setObjectAcl(String, String, String, AccessControlList)
but allows specifying a request metric collector.public void setObjectAcl(String bucketName, String key, String versionId, CannedAccessControlList acl) throws SdkClientException, AmazonServiceException
AmazonS3
Sets the CannedAccessControlList
for the specified object with the specified
version ID in Amazon S3 using one of the pre-configured
CannedAccessControlLists
.
A CannedAccessControlList
provides a quick way to configure an object or bucket with commonly used
access control policies.
Each bucket and object in Amazon S3 has an ACL that defines its access control policy and each version of an object has its own associated ACL. When a request is made, Amazon S3 authenticates the request using its standard authentication procedure and then checks the ACL to verify the sender was granted access to the bucket or object. If the sender is approved, the request proceeds. Otherwise, Amazon S3 returns an error.
For more information about enabling versioning for a bucket, see
AmazonS3.setBucketVersioningConfiguration(SetBucketVersioningConfigurationRequest)
.
setObjectAcl
in interface AmazonS3
bucketName
- The name of the bucket containing the object whose ACL is
being set.key
- The key of the object within the specified bucket whose ACL is
being set.versionId
- The version ID of the object version whose ACL is being set.acl
- The new pre-configured CannedAccessControlList
for the
specified object.SdkClientException
- If any errors are encountered in the client while making the
request or handling the response.AmazonServiceException
- If any errors occurred in Amazon S3 while processing the
request.AmazonS3.setObjectAcl(String, String, AccessControlList)
,
AmazonS3.setObjectAcl(String, String, CannedAccessControlList)
,
AmazonS3.setObjectAcl(String, String, String, AccessControlList)
,
Amazon Web Services API Documentationpublic void setObjectAcl(String bucketName, String key, String versionId, CannedAccessControlList acl, RequestMetricCollector requestMetricCollector)
AmazonS3Client.setObjectAcl(String, String, String, CannedAccessControlList)
but allows specifying a request metric collector.public void setObjectAcl(SetObjectAclRequest setObjectAclRequest) throws SdkClientException, AmazonServiceException
AmazonS3
AccessControlList
for the specified Amazon S3 object
with an optional version ID.
Each bucket and object in Amazon S3 has an ACL that defines its access control policy. When a request is made, Amazon S3 authenticates the request using its standard authentication procedure and then checks the ACL to verify the sender was granted access to the bucket or object. If the sender is approved, the request proceeds. Otherwise, Amazon S3 returns an error.
When constructing a custom AccessControlList
, callers
typically retrieve the existing AccessControlList
for a
bucket (AmazonS3Client.getObjectAcl(String, String)
), modify it
as necessary, and then use this method to upload the new ACL.
setObjectAcl
in interface AmazonS3
setObjectAclRequest
- The request object containing the S3 object to modify and the
ACL to set.SdkClientException
- If any errors are encountered in the client while making the
request or handling the response.AmazonServiceException
- If any errors occurred in Amazon S3 while processing the
request.public AccessControlList getBucketAcl(String bucketName) throws SdkClientException, AmazonServiceException
Gets the AccessControlList
(ACL) for the specified Amazon S3 bucket.
Each bucket and object in Amazon S3 has an ACL that defines its access control policy. When a request is made, Amazon S3 authenticates the request using its standard authentication procedure and then checks the ACL to verify the sender was granted access to the bucket or object. If the sender is approved, the request proceeds. Otherwise, Amazon S3 returns an error.
getBucketAcl
in interface AmazonS3
bucketName
- The name of the bucket whose ACL is being retrieved.AccessControlList
for the specified S3 bucket.SdkClientException
- If any errors are encountered in the client while making the
request or handling the response.AmazonServiceException
- If any errors occurred in Amazon S3 while processing the
request.AmazonS3Client.getBucketAcl(String)
public AccessControlList getBucketAcl(GetBucketAclRequest getBucketAclRequest) throws SdkClientException, AmazonServiceException
AmazonS3
AccessControlList
(ACL) for the specified Amazon S3
bucket.
Each bucket and object in Amazon S3 has an ACL that defines its access control policy. When a request is made, Amazon S3 authenticates the request using its standard authentication procedure and then checks the ACL to verify the sender was granted access to the bucket or object. If the sender is approved, the request proceeds. Otherwise, Amazon S3 returns an error.
getBucketAcl
in interface AmazonS3
getBucketAclRequest
- The request containing the name of the bucket whose ACL is
being retrieved.AccessControlList
for the specified S3 bucket.SdkClientException
- If any errors are encountered in the client while making the
request or handling the response.AmazonServiceException
- If any errors occurred in Amazon S3 while processing the
request.public void setBucketAcl(String bucketName, AccessControlList acl) throws SdkClientException, AmazonServiceException
AmazonS3
Sets the AccessControlList
for the specified Amazon S3 bucket.
Each bucket and object in Amazon S3 has an ACL that defines its access control policy. When a request is made, Amazon S3 authenticates the request using its standard authentication procedure and then checks the ACL to verify the sender was granted access to the bucket or object. If the sender is approved, the request proceeds. Otherwise, Amazon S3 returns an error.
When constructing a custom AccessControlList
, callers typically retrieve
the existing AccessControlList
for a bucket (
AmazonS3Client.getBucketAcl(String)
), modify it as necessary, and
then use this method to upload the new ACL.
setBucketAcl
in interface AmazonS3
bucketName
- The name of the bucket whose ACL is being set.acl
- The new AccessControlList for the specified bucket.SdkClientException
- If any errors are encountered in the client while making the
request or handling the response.AmazonServiceException
- If any errors occurred in Amazon S3 while processing the
request.AmazonS3.setBucketAcl(String, CannedAccessControlList)
,
Amazon Web Services API Documentationpublic void setBucketAcl(String bucketName, AccessControlList acl, RequestMetricCollector requestMetricCollector)
AmazonS3Client.setBucketAcl(String, AccessControlList)
but allows specifying a request metric collector.public void setBucketAcl(String bucketName, CannedAccessControlList cannedAcl) throws SdkClientException, AmazonServiceException
AmazonS3
Sets the CannedAccessControlList
for the specified Amazon S3 bucket using one of
the pre-configured CannedAccessControlLists
.
A CannedAccessControlList
provides a quick way to configure an object or bucket with commonly used
access control policies.
Each bucket and object in Amazon S3 has an ACL that defines its access control policy. When a request is made, Amazon S3 authenticates the request using its standard authentication procedure and then checks the ACL to verify the sender was granted access to the bucket or object. If the sender is approved, the request proceeds. Otherwise, Amazon S3 returns an error.
setBucketAcl
in interface AmazonS3
bucketName
- The name of the bucket whose ACL is being set.cannedAcl
- The pre-configured CannedAccessControlLists
to set for the
specified bucket.SdkClientException
- If any errors are encountered in the client while making the
request or handling the response.AmazonServiceException
- If any errors occurred in Amazon S3 while processing the
request.AmazonS3.setBucketAcl(String, AccessControlList)
,
Amazon Web Services API Documentationpublic void setBucketAcl(String bucketName, CannedAccessControlList cannedAcl, RequestMetricCollector requestMetricCollector) throws SdkClientException, AmazonServiceException
AmazonS3Client.setBucketAcl(String, CannedAccessControlList)
but allows specifying a request metric collector.public void setBucketAcl(SetBucketAclRequest setBucketAclRequest) throws SdkClientException, AmazonServiceException
AmazonS3
AccessControlList
for the specified Amazon S3 bucket.
Each bucket and object in Amazon S3 has an ACL that defines its access control policy. When a request is made, Amazon S3 authenticates the request using its standard authentication procedure and then checks the ACL to verify the sender was granted access to the bucket or object. If the sender is approved, the request proceeds. Otherwise, Amazon S3 returns an error.
When constructing a custom AccessControlList
, callers
typically retrieve the existing AccessControlList
for a
bucket ( AmazonS3Client.getBucketAcl(String)
), modify it as
necessary, and then use this method to upload the new ACL.
setBucketAcl
in interface AmazonS3
setBucketAclRequest
- The request object containing the bucket to modify and the ACL
to set.SdkClientException
- If any errors are encountered in the client while making the
request or handling the response.AmazonServiceException
- If any errors occurred in Amazon S3 while processing the
request.public ObjectMetadata getObjectMetadata(String bucketName, String key) throws SdkClientException, AmazonServiceException
AmazonS3
Gets the metadata for the specified Amazon S3 object without actually fetching the object itself. This is useful in obtaining only the object metadata, and avoids wasting bandwidth on fetching the object data.
The object metadata contains information such as content type, content disposition, etc., as well as custom user metadata that can be associated with an object in Amazon S3.
getObjectMetadata
in interface AmazonS3
bucketName
- The name of the bucket containing the object's whose metadata
is being retrieved.key
- The key of the object whose metadata is being retrieved.SdkClientException
- If any errors are encountered in the client while making the
request or handling the response.AmazonServiceException
- If any errors occurred in Amazon S3 while processing the
request.AmazonS3.getObjectMetadata(GetObjectMetadataRequest)
,
Amazon Web Services API Documentationpublic ObjectMetadata getObjectMetadata(GetObjectMetadataRequest getObjectMetadataRequest) throws SdkClientException, AmazonServiceException
AmazonS3
The HEAD action retrieves metadata from an object without returning the object itself. This action is useful if you're only interested in an object's metadata. To use HEAD, you must have READ access to the object.
A HEAD
request has the same options as a GET
action on an object. The response is identical
to the GET
response except that there is no response body. Because of this, if the HEAD
request
generates an error, it returns a generic 400 Bad Request
, 403 Forbidden
or 404 Not Found
code. It is not possible to retrieve the exact exception beyond these error codes.
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 retrieve the metadata from 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).
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 keys (SSE-S3). If your object does use these types of
keys, you’ll get an HTTP 400 BadRequest error.
The last modified property in this case is the creation date of the object.
Request headers are limited to 8 KB in size. For more information, see Common Request Headers.
Consider the following when using request headers:
Consideration 1 – 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 Amazon S3 returns 200 OK
and the data requested.
Consideration 2 – 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 Amazon S3 returns the 304 Not Modified
response code.
For more information about conditional requests, see RFC 7232.
Permissions
< p>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 returns an HTTP status code
404 (\"no such key\") error.
If you don’t have the s3:ListBucket
permission, Amazon S3 returns an HTTP status code 403
(\"access denied\") error.
The following action is related to HeadObject
:
getObjectMetadata
in interface AmazonS3
getObjectMetadataRequest
- The request object specifying the bucket, key and optional
version ID of the object whose metadata is being retrieved.SdkClientException
- If any errors are encountered on the client while making the
request or handling the response.AmazonServiceException
- If any errors occurred in Amazon S3 while processing the
request.AmazonS3.getObjectMetadata(String, String)
,
Amazon Web Services API Documentationpublic S3Object getObject(String bucketName, String key) throws SdkClientException, AmazonServiceException
AmazonS3
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.
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 KMS keys (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.
If you supply a versionId
, you need the s3:GetObjectVersion
permission to access a
specific version of an object. If you request a specific version, you do not need to have the
s3:GetObject
permission. If you request the current version without a specific version ID, only
s3:GetObject
permission is required. s3:GetObjectVersion
permission won't be required.
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
:
getObject
in interface AmazonS3
bucketName
- The name of the bucket containing the desired object.key
- The key under which the desired object is stored.SdkClientException
- If any errors are encountered in the client while making the
request or handling the response.AmazonServiceException
- If any errors occurred in Amazon S3 while processing the
request.AmazonS3.getObject(GetObjectRequest)
,
AmazonS3.getObject(GetObjectRequest, File)
,
Amazon Web Services API Documentationpublic boolean doesBucketExist(String bucketName) throws SdkClientException, AmazonServiceException
AmazonS3
Internally this uses the AmazonS3.headBucket(HeadBucketRequest)
operation to determine
whether the bucket exists.
doesBucketExist
in interface AmazonS3
bucketName
- The name of the bucket to check.true
if the specified bucket exists in
Amazon S3; the value false
if there is no bucket in
Amazon S3 with that name.SdkClientException
- If any errors are encountered in the client while making the
request or handling the response.AmazonServiceException
- If any errors occurred in Amazon S3 while processing the
request.AmazonS3.createBucket(CreateBucketRequest)
public boolean doesBucketExistV2(String bucketName) throws SdkClientException
AmazonS3
Internally this uses the AmazonS3.getBucketAcl(String)
operation to determine
whether the bucket exists.
doesBucketExistV2
in interface AmazonS3
bucketName
- The name of the bucket to check.true
if the specified bucket exists in
Amazon S3; the value false
if there is no bucket in
Amazon S3 with that name.SdkClientException
- If any errors are encountered in the client while making the
request or handling the response.AmazonServiceException
- If any errors occurred in Amazon S3 while processing the
request.AmazonS3.createBucket(CreateBucketRequest)
public boolean doesObjectExist(String bucketName, String objectName) throws AmazonServiceException, SdkClientException
doesObjectExist
in interface AmazonS3
bucketName
- Name of bucket that presumably contains objectobjectName
- Name of object that has to be checkedAmazonServiceException
- If any errors occurred in Amazon S3 while processing the
request.SdkClientException
- If any errors are encountered in the client while making the
request or handling the response.public HeadBucketResult headBucket(HeadBucketRequest headBucketRequest) throws SdkClientException, AmazonServiceException
AmazonS3
This action is useful to determine if a bucket exists and you have permission to access it. The action returns a
200 OK
if the bucket exists and you have permission to access it.
If the bucket does not exist or you do not have permission to access it, the HEAD
request returns a
generic 400 Bad Request
, 403 Forbidden
or 404 Not Found
code. A message
body is not included, so you cannot determine the exception beyond these error codes.
To use this operation, you must have permissions to perform the s3:ListBucket
action. The bucket
owner has this permission by default and can grant this permission to others. For more information about
permissions, see Permissions Related to Bucket Subresource Operations and Managing Access Permissions
to Your Amazon S3 Resources.
To use this API against an access point, you must provide the alias of the access point in place of the bucket name or specify the access point ARN. When using the access point ARN, 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 the Amazon Web Services SDKs, you provide the ARN in place of the bucket name. For more information see, Using access points.
headBucket
in interface AmazonS3
headBucketRequest
- The request containing the bucket name.HeadBucketResult
if the bucket exists and you have
permission to access it. Otherwise, the method will throw an
AmazonServiceException
with status code '404 Not Found'
if the bucket
does not exist, '403 Forbidden'
if the user does not have access to the
bucket, or '301 Moved Permanently'
if the bucket is in a different region
than the client is configured withSdkClientException
- If any errors are encountered in the client while making the request or handling
the response.AmazonServiceException
- If any errors occurred in Amazon S3 while processing the request.public void changeObjectStorageClass(String bucketName, String key, StorageClass newStorageClass) throws SdkClientException, AmazonServiceException
AmazonS3
Changes the Amazon S3 storage class for a specified object. Amazon S3 offers multiple storage classes for developers' different needs.
Note that changing the storage class of an object in a bucket that has enabled versioning creates a new version of the object with the new storage class. The existing version of the object persists in the current storage class.
changeObjectStorageClass
in interface AmazonS3
bucketName
- The name of the bucket containing the object.key
- The key of the object within the specified bucket.newStorageClass
- The new storage class for the specified object.SdkClientException
- If any errors are encountered in the client while making the
request or handling the response.AmazonServiceException
- If any errors occurred in Amazon S3 while processing the
request.public void setObjectRedirectLocation(String bucketName, String key, String newRedirectLocation) throws SdkClientException, AmazonServiceException
AmazonS3
Changes the Amazon S3 redirect location for a specific object.
setObjectRedirectLocation
in interface AmazonS3
bucketName
- The name of the bucket containing the object.key
- The key of the object within the specified bucket.newRedirectLocation
- The new redirect location for the specified object.SdkClientException
- If any errors are encountered in the client while making the
request or handling the response.AmazonServiceException
- If any errors occurred in Amazon S3 while processing the
request.public S3Object getObject(GetObjectRequest getObjectRequest) throws SdkClientException, AmazonServiceException
AmazonS3
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.
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 KMS keys (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.
If you supply a versionId
, you need the s3:GetObjectVersion
permission to access a
specific version of an object. If you request a specific version, you do not need to have the
s3:GetObject
permission. If you request the current version without a specific version ID, only
s3:GetObject
permission is required. s3:GetObjectVersion
permission won't be required.
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
:
getObject
in interface AmazonS3
getObject
in interface S3DirectSpi
getObjectRequest
- The request object containing all the options on how to
download the object.null
if constraints were specified but not met.SdkClientException
- If any errors are encountered in the client while making the
request or handling the response.AmazonServiceException
- If any errors occurred in Amazon S3 while processing the
request.AmazonS3.getObject(String, String)
,
AmazonS3.getObject(GetObjectRequest, File)
,
Amazon Web Services API Documentationpublic ObjectMetadata getObject(GetObjectRequest getObjectRequest, File destinationFile) throws SdkClientException, AmazonServiceException
AmazonS3
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.
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 KMS keys (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.
If you supply a versionId
, you need the s3:GetObjectVersion
permission to access a
specific version of an object. If you request a specific version, you do not need to have the
s3:GetObject
permission. If you request the current version without a specific version ID, only
s3:GetObject
permission is required. s3:GetObjectVersion
permission won't be required.
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
:
getObject
in interface AmazonS3
getObject
in interface S3DirectSpi
getObjectRequest
- The request object containing all the options on how to
download the Amazon S3 object content.destinationFile
- Indicates the file (which might already exist) where
to save the object content being downloading from Amazon S3.null
if constraints were specified but not met.SdkClientException
- If any errors are encountered in the client while making the
request, handling the response, or writing the incoming data
from S3 to the specified destination file.AmazonServiceException
- If any errors occurred in Amazon S3 while processing the
request.AmazonS3.getObject(String, String)
,
AmazonS3.getObject(GetObjectRequest)
,
Amazon Web Services API Documentationpublic String getObjectAsString(String bucketName, String key) throws AmazonServiceException, SdkClientException
AmazonS3
Retrieves and decodes the contents of an S3 object to a String.
getObjectAsString
in interface AmazonS3
bucketName
- The name of the bucket containing the object to retrieve.key
- The key of the object to retrieve.AmazonServiceException
SdkClientException
public com.ibm.cloud.objectstorage.services.s3.model.GetObjectTaggingResult getObjectTagging(com.ibm.cloud.objectstorage.services.s3.model.GetObjectTaggingRequest getObjectTaggingRequest)
AmazonS3
getObjectTagging
in interface AmazonS3
getObjectTaggingRequest
- The request object containing all the options on how to
retrieve the Amazon S3 object tags.public com.ibm.cloud.objectstorage.services.s3.model.SetObjectTaggingResult setObjectTagging(com.ibm.cloud.objectstorage.services.s3.model.SetObjectTaggingRequest setObjectTaggingRequest)
AmazonS3
setObjectTagging
in interface AmazonS3
setObjectTaggingRequest
- The request object containing all the options for setting the
tags for the specified object.public com.ibm.cloud.objectstorage.services.s3.model.DeleteObjectTaggingResult deleteObjectTagging(com.ibm.cloud.objectstorage.services.s3.model.DeleteObjectTaggingRequest deleteObjectTaggingRequest)
AmazonS3
Removes the entire tag set from the specified object. For more information about managing object tags, see Object Tagging.
To use this operation, you must have permission to perform the s3:DeleteObjectTagging
action.
To delete tags of a specific object version, add the versionId
query parameter in the request. You
will need permission for the s3:DeleteObjectVersionTagging
action.
The following operations are related to DeleteObjectTagging
:
deleteObjectTagging
in interface AmazonS3
deleteObjectTaggingRequest
- The request object containing all the options for deleting
the tags for the specified object.DeleteObjectTaggingResult
object containing the
information returned by S3 for the the tag deletion.public void deleteBucket(String bucketName) throws SdkClientException, AmazonServiceException
AmazonS3
Deletes the specified bucket. All objects (and all object versions, if versioning was ever enabled) in the bucket must be deleted before the bucket itself can be deleted.
Only the owner of a bucket can delete it, regardless of the bucket's access control policy.
deleteBucket
in interface AmazonS3
bucketName
- The name of the bucket to delete.SdkClientException
- If any errors are encountered in the client while making the
request or handling the response.AmazonServiceException
- If any errors occurred in Amazon S3 while processing the
request.AmazonS3.deleteBucket(String)
,
Amazon Web Services API Documentationpublic void deleteBucket(DeleteBucketRequest deleteBucketRequest) throws SdkClientException, AmazonServiceException
AmazonS3
Deletes the specified bucket. All objects (and all object versions, if versioning was ever enabled) in the bucket must be deleted before the bucket itself can be deleted.
Only the owner of a bucket can delete it, regardless of the bucket's access control policy (ACL).
deleteBucket
in interface AmazonS3
deleteBucketRequest
- The request object containing all options for deleting an Amazon S3
bucket.SdkClientException
- If any errors are encountered in the client while making the
request or handling the response.AmazonServiceException
- If any errors occurred in Amazon S3 while processing the
request.AmazonS3.deleteBucket(String)
,
Amazon Web Services API Documentationpublic PutObjectResult putObject(String bucketName, String key, File file) throws SdkClientException, AmazonServiceException
AmazonS3
Uploads the specified file to Amazon S3 under the specified bucket and key name.
Amazon S3 never stores partial objects; if during this call an exception wasn't thrown, the entire object was stored.
If you are uploading or accessing Amazon Web Services KMS-encrypted objects, you need to specify the correct region of the bucket on your client and configure Amazon Web Services Signature Version 4 for added security. For more information on how to do this, see http://docs.aws.amazon.com/AmazonS3/latest/dev/UsingAWSSDK.html# specify-signature-version
The client automatically computes a checksum of the file. Amazon S3 uses checksums to validate the data in each file.
Using the file extension, Amazon S3 attempts to determine the correct content type and content disposition to use for the object.
If versioning is enabled for the specified bucket,
this operation will never overwrite an existing object
with the same key, but will keep the existing object as an
older version
until that version is
explicitly deleted (see
AmazonS3.deleteVersion(String, String, String)
.
If versioning is not enabled, this operation will overwrite an existing object with the same key; Amazon S3 will store the last write request. Amazon S3 does not provide object locking. If Amazon S3 receives multiple write requests for the same object nearly simultaneously, all of the objects might be stored. However, a single object will be stored with the final write request.
When specifying a location constraint when creating a bucket, all objects added to the bucket are stored in the bucket's region. For example, if specifying a Europe (EU) region constraint for a bucket, all of that bucket's objects are stored in EU region.
The specified bucket must already exist and the caller must have
Permission.Write
permission to the bucket to upload an object.
putObject
in interface AmazonS3
bucketName
- The name of an existing bucket, to which you have
Permission.Write
permission.key
- The key under which to store the specified file.file
- The file containing the data to be uploaded to Amazon S3.PutObjectResult
object containing the information
returned by Amazon S3 for the newly created object.SdkClientException
- If any errors are encountered in the client while making the
request or handling the response.AmazonServiceException
- If any errors occurred in Amazon S3 while processing the
request.AmazonS3.putObject(PutObjectRequest)
,
AmazonS3.putObject(String, String, InputStream, ObjectMetadata)
,
Amazon Web Services API Documentationpublic PutObjectResult putObject(String bucketName, String key, InputStream input, ObjectMetadata metadata) throws SdkClientException, AmazonServiceException
AmazonS3
Uploads the specified input stream and object metadata to Amazon S3 under the specified bucket and key name.
Amazon S3 never stores partial objects; if during this call an exception wasn't thrown, the entire object was stored.
If you are uploading or accessing Amazon Web Services KMS-encrypted objects, you need to specify the correct region of the bucket on your client and configure Amazon Web Services Signature Version 4 for added security. For more information on how to do this, see http://docs.aws.amazon.com/AmazonS3/latest/dev/UsingAWSSDK.html# specify-signature-version
The client automatically computes a checksum of the file. This checksum is verified against another checksum that is calculated once the data reaches Amazon S3, ensuring the data has not corrupted in transit over the network.
Using the file extension, Amazon S3 attempts to determine the correct content type and content disposition to use for the object.
Content length must be specified before data can be uploaded to Amazon S3. If the caller doesn't provide it, the library will make a best effort to compute the content length by buffer the contents of the input stream into the memory because Amazon S3 explicitly requires that the content length be sent in the request headers before any of the data is sent. Please note that this operation is not guaranteed to succeed.
When using an BufferedInputStream
as data source,
please remember to use a buffer of size no less than
RequestClientOptions.DEFAULT_STREAM_BUFFER_SIZE
while initializing the BufferedInputStream.
This is to ensure that the SDK can correctly mark and reset the stream with
enough memory buffer during signing and retries.
If versioning is enabled for the specified bucket, this operation will
never overwrite an existing object at the same key, but instead will keep
the existing object around as an older version until that version is
explicitly deleted (see
AmazonS3.deleteVersion(String, String, String)
.
If versioning is not enabled, this operation will overwrite an existing object with the same key; Amazon S3 will store the last write request. Amazon S3 does not provide object locking. If Amazon S3 receives multiple write requests for the same object nearly simultaneously, all of the objects might be stored. However, a single object will be stored with the final write request.
When specifying a location constraint when creating a bucket, all objects added to the bucket are stored in the bucket's region. For example, if specifying a Europe (EU) region constraint for a bucket, all of that bucket's objects are stored in EU region.
The specified bucket must already exist and the caller must have
Permission.Write
permission to the bucket to upload an object.
putObject
in interface AmazonS3
bucketName
- The name of an existing bucket, to which you have
Permission.Write
permission.key
- The key under which to store the specified file.input
- The input stream containing the data to be uploaded to Amazon
S3.metadata
- Additional metadata instructing Amazon S3 how to handle the
uploaded data (e.g. custom user metadata, hooks for specifying
content type, etc.).PutObjectResult
object containing the information
returned by Amazon S3 for the newly created object.SdkClientException
- If any errors are encountered in the client while making the
request or handling the response.AmazonServiceException
- If any errors occurred in Amazon S3 while processing the
request.AmazonS3.putObject(String, String, File)
,
AmazonS3.putObject(PutObjectRequest)
,
Amazon Web Services API Documentationpublic PutObjectResult putObject(PutObjectRequest putObjectRequest) throws SdkClientException, AmazonServiceException
AmazonS3
Uploads a new object to the specified Amazon S3 bucket. The
PutObjectRequest
contains all the details of the request,
including the bucket to upload to, the key the object will be uploaded
under, and the file or input stream containing the data to upload.
Amazon S3 never stores partial objects; if during this call an exception wasn't thrown, the entire object was stored.
If you are uploading or accessing Amazon Web Services KMS-encrypted objects, you need to specify the correct region of the bucket on your client and configure Amazon Web Services Signature Version 4 for added security. For more information on how to do this, see http://docs.aws.amazon.com/AmazonS3/latest/dev/UsingAWSSDK.html# specify-signature-version
Depending on whether a file or input stream is being uploaded, this method has slightly different behavior.
When uploading a file:
When uploading directly from an input stream:
If versioning is enabled for the specified bucket, this operation will
never overwrite an existing object with the same key, but will keep the
existing object as an older version until that version is explicitly
deleted (see AmazonS3.deleteVersion(String, String, String)
.
If versioning is not enabled, this operation will overwrite an existing object with the same key; Amazon S3 will store the last write request. Amazon S3 does not provide object locking. If Amazon S3 receives multiple write requests for the same object nearly simultaneously, all of the objects might be stored. However, a single object will be stored with the final write request.
When specifying a location constraint when creating a bucket, all objects added to the bucket are stored in the bucket's region. For example, if specifying a Europe (EU) region constraint for a bucket, all of that bucket's objects are stored in the EU region.
The specified bucket must already exist and the caller must have
Permission.Write
permission to the bucket to upload an object.
putObject
in interface AmazonS3
putObject
in interface S3DirectSpi
putObjectRequest
- The request object containing all the parameters to upload a
new object to Amazon S3.PutObjectResult
object containing the information
returned by Amazon S3 for the newly created object.SdkClientException
- If any errors are encountered in the client while making the
request or handling the response.AmazonServiceException
- If any errors occurred in Amazon S3 while processing the
request.AmazonS3.putObject(String, String, File)
,
AmazonS3.putObject(String, String, InputStream, ObjectMetadata)
,
Amazon Web Services API Documentationpublic CopyObjectResult copyObject(String sourceBucketName, String sourceKey, String destinationBucketName, String destinationKey) throws SdkClientException, AmazonServiceException
AmazonS3
Copies a source object to a new destination in Amazon S3.
By default, all object metadata for the source object except
server-side-encryption, storage-class and
website-redirect-location are copied to the new destination
object, unless new object metadata in the specified
CopyObjectRequest
is provided.
The Amazon S3 Acccess Control List (ACL) is not copied to the new
object. The new object will have the default Amazon S3 ACL,
CannedAccessControlList.Private
, unless one is explicitly
provided in the specified CopyObjectRequest
.
To copy an object, the caller's account must have read access to the source object and write access to the destination bucket
This method only exposes the basic options for copying an Amazon S3
object. Additional options are available by calling the
AmazonS3Client.copyObject(CopyObjectRequest)
method, including
conditional constraints for copying objects, setting ACLs, overwriting
object metadata, etc.
If you are copying Amazon Web Services KMS-encrypted objects, you need to specify the correct region of the bucket on your client and configure Amazon Web Services Signature Version 4 for added security. For more information on how to do this, see http://docs.aws.amazon.com/AmazonS3/latest/dev/UsingAWSSDK.html# specify-signature-version
copyObject
in interface AmazonS3
sourceBucketName
- The name of the bucket containing the source object to copy.sourceKey
- The key in the source bucket under which the source object is stored.destinationBucketName
- The name of the bucket in which the new object will be
created. This can be the same name as the source bucket's.destinationKey
- The key in the destination bucket under which the new object
will be created.CopyObjectResult
object containing the information
returned by Amazon S3 for the newly created object.SdkClientException
- If any errors are encountered in the client while making the
request or handling the response.AmazonServiceException
- If any errors occurred in Amazon S3 while processing the
request.AmazonS3Client.copyObject(CopyObjectRequest)
,
Amazon Web Services API Documentationpublic CopyObjectResult copyObject(CopyObjectRequest copyObjectRequest) throws SdkClientException, AmazonServiceException
AmazonS3
Copies a source object to a new destination in Amazon S3.
By default, all object metadata for the source object except
server-side-encryption, storage-class and
website-redirect-location are copied to the new destination
object, unless new object metadata in the specified
CopyObjectRequest
is provided.
The Amazon S3 Acccess Control List (ACL) is not copied to the new
object. The new object will have the default Amazon S3 ACL,
CannedAccessControlList.Private
, unless one is explicitly
provided in the specified CopyObjectRequest
.
To copy an object, the caller's account must have read access to the source object and write access to the destination bucket.
If constraints are specified in the CopyObjectRequest
(e.g.
CopyObjectRequest.setMatchingETagConstraints(List)
) and are not
satisfied when Amazon S3 receives the request, this method returns
null
. This method returns a non-null result under all other
circumstances.
This method exposes all the advanced options for copying an Amazon S3
object. For simple needs, use the
AmazonS3Client.copyObject(String, String, String, String)
method.
If you are copying Amazon Web Services KMS-encrypted objects, you need to specify the correct region of the bucket on your client and configure Amazon Web Services Signature Version 4 for added security. For more information on how to do this, see http://docs.aws.amazon.com/AmazonS3/latest/dev/UsingAWSSDK.html# specify-signature-version
copyObject
in interface AmazonS3
copyObjectRequest
- The request object containing all the options for copying an
Amazon S3 object.CopyObjectResult
object containing the information
returned by Amazon S3 about the newly created object, or
null
if constraints were specified that weren't met
when Amazon S3 attempted to copy the object.SdkClientException
- If any errors are encountered in the client while making the
request or handling the response.AmazonServiceException
- If any errors occurred in Amazon S3 while processing the
request.AmazonS3Client.copyObject(String, String, String, String)
,
Amazon Web Services API Documentationpublic CopyPartResult copyPart(CopyPartRequest copyPartRequest)
For information about maximum and minimum part sizes and other multipart upload specifications, see Multipart upload limits in the Amazon S3 User Guide.
If constraints are specified in the CopyPartRequest
(e.g.
CopyPartRequest.setMatchingETagConstraints(List)
)
and are not satisfied when Amazon S3 receives the
request, this method returns null
.
This method returns a non-null result under all other
circumstances.
copyPart
in interface AmazonS3
copyPart
in interface S3DirectSpi
copyPartRequest
- The request object containing all the options for copying an
Amazon S3 object.CopyPartResult
object containing the information
returned by Amazon S3 about the newly created object, or null
if
constraints were specified that weren't met when Amazon S3 attempted
to copy the object.SdkClientException
- If any errors are encountered in the client while making the
request or handling the response.AmazonServiceException
- If any errors occurred in Amazon S3 while processing the
request.AmazonS3.copyObject(CopyObjectRequest)
,
AmazonS3.initiateMultipartUpload(InitiateMultipartUploadRequest)
public void deleteObject(String bucketName, String key) throws SdkClientException, AmazonServiceException
AmazonS3
Deletes the specified object in the specified bucket. Once deleted, the object can only be restored if versioning was enabled when the object was deleted.
If attempting to delete an object that does not exist, Amazon S3 returns a success message instead of an error message.
deleteObject
in interface AmazonS3
bucketName
- The name of the Amazon S3 bucket containing the object to
delete.key
- The key of the object to delete.SdkClientException
- If any errors are encountered in the client while making the
request or handling the response.AmazonServiceException
- If any errors occurred in Amazon S3 while processing the
request.AmazonS3Client.deleteObject(DeleteObjectRequest)
,
Amazon Web Services API Documentationpublic void deleteObject(DeleteObjectRequest deleteObjectRequest) throws SdkClientException, AmazonServiceException
AmazonS3
Deletes the specified object in the specified bucket. Once deleted, the object can only be restored if versioning was enabled when the object was deleted.
If attempting to delete an object that does not exist, Amazon S3 will return a success message instead of an error message.
deleteObject
in interface AmazonS3
deleteObjectRequest
- The request object containing all options for deleting an Amazon S3
object.SdkClientException
- If any errors are encountered in the client while making the
request or handling the response.AmazonServiceException
- If any errors occurred in Amazon S3 while processing the
request.AmazonS3Client.deleteObject(String, String)
,
Amazon Web Services API Documentationpublic DeleteObjectsResult deleteObjects(DeleteObjectsRequest deleteObjectsRequest)
AmazonS3
In some cases, some objects will be successfully deleted, while some
attempts will cause an error. If any object in the request cannot be
deleted, this method throws a MultiObjectDeleteException
with
details of the error.
deleteObjects
in interface AmazonS3
deleteObjectsRequest
- The request object containing all options for deleting
multiple objects.public void deleteVersion(String bucketName, String key, String versionId) throws SdkClientException, AmazonServiceException
AmazonS3
Deletes a specific version of the specified object in the specified bucket. Once deleted, there is no method to restore or undelete an object version. This is the only way to permanently delete object versions that are protected by versioning.
Deleting an object version is permanent and irreversible. It is a privileged operation that only the owner of the bucket containing the version can perform.
Users can only delete a version of an object if versioning is enabled
for the bucket.
For more information about enabling versioning for a bucket, see
AmazonS3.setBucketVersioningConfiguration(SetBucketVersioningConfigurationRequest)
.
If attempting to delete an object that does not exist, Amazon S3 will return a success message instead of an error message.
deleteVersion
in interface AmazonS3
bucketName
- The name of the Amazon S3 bucket containing the object to
delete.key
- The key of the object to delete.versionId
- The version of the object to delete.SdkClientException
- If any errors are encountered in the client while making the
request or handling the response.AmazonServiceException
- If any errors occurred in Amazon S3 while processing the
request.public void deleteVersion(DeleteVersionRequest deleteVersionRequest) throws SdkClientException, AmazonServiceException
AmazonS3
Deletes a specific version of an object in the specified bucket. Once deleted, there is no method to restore or undelete an object version. This is the only way to permanently delete object versions that are protected by versioning.
Deleting an object version is permanent and irreversible. It is a privileged operation that only the owner of the bucket containing the version can perform.
Users can only delete a version of an object if versioning is enabled
for the bucket.
For more information about enabling versioning for a bucket, see
AmazonS3.setBucketVersioningConfiguration(SetBucketVersioningConfigurationRequest)
.
If attempting to delete an object that does not exist, Amazon S3 will return a success message instead of an error message.
deleteVersion
in interface AmazonS3
deleteVersionRequest
- The request object containing all options for deleting a
specific version of an Amazon S3 object.SdkClientException
- If any errors are encountered in the client while making the
request or handling the response.AmazonServiceException
- If any errors occurred in Amazon S3 while processing the
request.public void setBucketVersioningConfiguration(SetBucketVersioningConfigurationRequest setBucketVersioningConfigurationRequest) throws SdkClientException, AmazonServiceException
AmazonS3
Sets the versioning configuration for the specified bucket.
A bucket's versioning configuration can be in one of three possible states:
BucketVersioningConfiguration.OFF
BucketVersioningConfiguration.ENABLED
BucketVersioningConfiguration.SUSPENDED
By default, new buckets are in the
off
state. Once versioning is
enabled for a bucket the status can never be reverted to
off
.
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.
The versioning configuration of a bucket has different implications for
each operation performed on that bucket or for objects within that
bucket. For example, when versioning is enabled a PutObject
operation creates a unique object version-id for the object being uploaded. The
The PutObject
API guarantees that, if versioning is enabled for a bucket at
the time of the request, the new object can only be permanently deleted
using a DeleteVersion
operation. It can never be overwritten.
Additionally, the PutObject
API guarantees that,
if versioning is enabled for a bucket the request,
no other object will be overwritten by that request.
Refer to the documentation sections for each API for information on how
versioning status affects the semantics of that particular API.
Amazon S3 is eventually consistent. It can take time for the versioning status of a bucket to be propagated throughout the system.
setBucketVersioningConfiguration
in interface AmazonS3
setBucketVersioningConfigurationRequest
- The request object containing all options for setting the
bucket versioning configuration.SdkClientException
- If any errors are encountered in the client while making the
request or handling the response.AmazonServiceException
- If any errors occurred in Amazon S3 while processing the
request.AmazonS3.getBucketVersioningConfiguration(String)
,
Amazon Web Services API Documentationpublic BucketVersioningConfiguration getBucketVersioningConfiguration(String bucketName) throws SdkClientException, AmazonServiceException
AmazonS3
Returns the versioning configuration for the specified bucket.
A bucket's versioning configuration can be in one of three possible states:
BucketVersioningConfiguration.OFF
BucketVersioningConfiguration.ENABLED
BucketVersioningConfiguration.SUSPENDED
By default, new buckets are in the
off
state. Once versioning is
enabled for a bucket the status can never be reverted to
off
.
The versioning configuration of a bucket has different implications for
each operation performed on that bucket or for objects within that
bucket. For example, when versioning is enabled a PutObject
operation creates a unique object version-id for the object being uploaded. The
The PutObject
API guarantees that, if versioning is enabled for a bucket at
the time of the request, the new object can only be permanently deleted
using a DeleteVersion
operation. It can never be overwritten.
Additionally, the PutObject
API guarantees that,
if versioning is enabled for a bucket the request,
no other object will be overwritten by that request.
Refer to the documentation sections for each API for information on how
versioning status affects the semantics of that particular API.
Amazon S3 is eventually consistent. It can take time for the versioning status of a bucket to be propagated throughout the system.
getBucketVersioningConfiguration
in interface AmazonS3
bucketName
- The bucket whose versioning configuration will be retrieved.SdkClientException
- If any errors are encountered in the client while making the
request or handling the response.AmazonServiceException
- If any errors occurred in Amazon S3 while processing the
request.AmazonS3.setBucketVersioningConfiguration(SetBucketVersioningConfigurationRequest)
,
AmazonS3.getBucketVersioningConfiguration(GetBucketVersioningConfigurationRequest)
,
Amazon Web Services API Documentationpublic BucketVersioningConfiguration getBucketVersioningConfiguration(GetBucketVersioningConfigurationRequest getBucketVersioningConfigurationRequest) throws SdkClientException, AmazonServiceException
AmazonS3
Returns the versioning configuration for the specified bucket.
A bucket's versioning configuration can be in one of three possible states:
BucketVersioningConfiguration.OFF
BucketVersioningConfiguration.ENABLED
BucketVersioningConfiguration.SUSPENDED
By default, new buckets are in the
off
state. Once versioning is
enabled for a bucket the status can never be reverted to
off
.
The versioning configuration of a bucket has different implications for
each operation performed on that bucket or for objects within that
bucket. For example, when versioning is enabled a PutObject
operation creates a unique object version-id for the object being uploaded. The
The PutObject
API guarantees that, if versioning is enabled for a bucket at
the time of the request, the new object can only be permanently deleted
using a DeleteVersion
operation. It can never be overwritten.
Additionally, the PutObject
API guarantees that,
if versioning is enabled for a bucket the request,
no other object will be overwritten by that request.
Refer to the documentation sections for each API for information on how
versioning status affects the semantics of that particular API.
Amazon S3 is eventually consistent. It can take time for the versioning status of a bucket to be propagated throughout the system.
getBucketVersioningConfiguration
in interface AmazonS3
getBucketVersioningConfigurationRequest
- The request object for retrieving the bucket versioning configuration.SdkClientException
- If any errors are encountered in the client while making the
request or handling the response.AmazonServiceException
- If any errors occurred in Amazon S3 while processing the
request.AmazonS3.setBucketVersioningConfiguration(SetBucketVersioningConfigurationRequest)
,
AmazonS3.getBucketVersioningConfiguration(String)
,
Amazon Web Services API Documentationpublic BucketWebsiteConfiguration getBucketWebsiteConfiguration(String bucketName) throws SdkClientException, AmazonServiceException
AmazonS3
For more information on how to host a website on Amazon S3, see: http://docs.amazonwebservices.com/AmazonS3/latest/dev/WebsiteHosting.html.
This operation requires the S3:GetBucketWebsite
permission.
By default, only the bucket owner can read the bucket website
configuration. However, bucket owners can allow other users to read the
website configuration by writing a bucket policy granting them the
S3:GetBucketWebsite
permission.
getBucketWebsiteConfiguration
in interface AmazonS3
bucketName
- The name of the bucket whose website configuration is being
retrieved.SdkClientException
- If any errors are encountered on the client while making the
request or handling the response.AmazonServiceException
- If any errors occurred in Amazon S3 while processing the
request.public BucketWebsiteConfiguration getBucketWebsiteConfiguration(GetBucketWebsiteConfigurationRequest getBucketWebsiteConfigurationRequest) throws SdkClientException, AmazonServiceException
AmazonS3
For more information on how to host a website on Amazon S3, see: http://docs.amazonwebservices.com/AmazonS3/latest/dev/WebsiteHosting. html.
This operation requires the S3:GetBucketWebsite
permission.
By default, only the bucket owner can read the bucket website
configuration. However, bucket owners can allow other users to read the
website configuration by writing a bucket policy granting them the
S3:GetBucketWebsite
permission.
getBucketWebsiteConfiguration
in interface AmazonS3
getBucketWebsiteConfigurationRequest
- The request object for retrieving the bucket website configuration.SdkClientException
- If any errors are encountered on the client while making the
request or handling the response.AmazonServiceException
- If any errors occurred in Amazon S3 while processing the
request.public BucketLifecycleConfiguration getBucketLifecycleConfiguration(String bucketName)
AmazonS3
getBucketLifecycleConfiguration
in interface AmazonS3
bucketName
- The name of the bucket for which to retrieve lifecycle
configuration.AmazonS3.getBucketLifecycleConfiguration(GetBucketLifecycleConfigurationRequest)
,
Amazon Web Services API Documentationpublic BucketLifecycleConfiguration getBucketLifecycleConfiguration(GetBucketLifecycleConfigurationRequest getBucketLifecycleConfigurationRequest)
AmazonS3
getBucketLifecycleConfiguration
in interface AmazonS3
getBucketLifecycleConfigurationRequest
- The request object for retrieving the bucket lifecycle
configuration.AmazonS3.getBucketLifecycleConfiguration(String)
,
Amazon Web Services API Documentationpublic void setBucketLifecycleConfiguration(String bucketName, BucketLifecycleConfiguration bucketLifecycleConfiguration)
AmazonS3
setBucketLifecycleConfiguration
in interface AmazonS3
bucketName
- The name of the bucket for which to set the lifecycle
configuration.bucketLifecycleConfiguration
- The new lifecycle configuration for this bucket, which
completely replaces any existing configuration.public void setBucketLifecycleConfiguration(SetBucketLifecycleConfigurationRequest setBucketLifecycleConfigurationRequest)
AmazonS3
setBucketLifecycleConfiguration
in interface AmazonS3
setBucketLifecycleConfigurationRequest
- The request object containing all options for setting the
bucket lifecycle configuration.public void deleteBucketLifecycleConfiguration(String bucketName)
AmazonS3
deleteBucketLifecycleConfiguration
in interface AmazonS3
bucketName
- The name of the bucket for which to remove the lifecycle
configuration.public void deleteBucketLifecycleConfiguration(DeleteBucketLifecycleConfigurationRequest deleteBucketLifecycleConfigurationRequest)
AmazonS3
deleteBucketLifecycleConfiguration
in interface AmazonS3
deleteBucketLifecycleConfigurationRequest
- The request object containing all options for removing the
bucket lifecycle configuration.public BucketCrossOriginConfiguration getBucketCrossOriginConfiguration(String bucketName)
AmazonS3
getBucketCrossOriginConfiguration
in interface AmazonS3
bucketName
- The name of the bucket for which to retrieve cross origin
configuration.AmazonS3.getBucketCrossOriginConfiguration(GetBucketCrossOriginConfigurationRequest)
,
Amazon Web Services API Documentationpublic BucketCrossOriginConfiguration getBucketCrossOriginConfiguration(GetBucketCrossOriginConfigurationRequest getBucketCrossOriginConfigurationRequest)
AmazonS3
getBucketCrossOriginConfiguration
in interface AmazonS3
getBucketCrossOriginConfigurationRequest
- The request object for retrieving the bucket cross origin
configuration.AmazonS3.getBucketCrossOriginConfiguration(String)
,
Amazon Web Services API Documentationpublic void setBucketCrossOriginConfiguration(String bucketName, BucketCrossOriginConfiguration bucketCrossOriginConfiguration)
AmazonS3
setBucketCrossOriginConfiguration
in interface AmazonS3
bucketName
- The name of the bucket for which to retrieve cross origin
configuration.bucketCrossOriginConfiguration
- The new cross origin configuration for this bucket, which
completely replaces any existing configuration.public void setBucketCrossOriginConfiguration(SetBucketCrossOriginConfigurationRequest setBucketCrossOriginConfigurationRequest)
AmazonS3
setBucketCrossOriginConfiguration
in interface AmazonS3
setBucketCrossOriginConfigurationRequest
- The request object containing all options for setting the
bucket cross origin configuration.public void deleteBucketCrossOriginConfiguration(String bucketName)
AmazonS3
deleteBucketCrossOriginConfiguration
in interface AmazonS3
bucketName
- The name of the bucket for which to retrieve cross origin
configuration.public void deleteBucketCrossOriginConfiguration(DeleteBucketCrossOriginConfigurationRequest deleteBucketCrossOriginConfigurationRequest)
AmazonS3
deleteBucketCrossOriginConfiguration
in interface AmazonS3
deleteBucketCrossOriginConfigurationRequest
- The request object containing all options for deleting the
bucket cross origin configuration.public void setBucketWebsiteConfiguration(String bucketName, BucketWebsiteConfiguration configuration) throws SdkClientException, AmazonServiceException
AmazonS3
For more information on how to host a website on Amazon S3, see: http://docs.amazonwebservices.com/AmazonS3/latest/dev/WebsiteHosting.html.
This operation requires the S3:PutBucketWebsite
permission.
By default, only the bucket owner can configure the website attached to a
bucket. However, bucket owners can allow other users to set the website
configuration by writing a bucket policy granting them the
S3:PutBucketWebsite
permission.
setBucketWebsiteConfiguration
in interface AmazonS3
bucketName
- The name of the bucket whose website configuration is being
set.configuration
- The configuration describing how the specified bucket will
serve web requests (i.e. default index page, error page).SdkClientException
- If any errors are encountered on the client while making the
request or handling the response.AmazonServiceException
- If any errors occurred in Amazon S3 while processing the
request.public void setBucketWebsiteConfiguration(SetBucketWebsiteConfigurationRequest setBucketWebsiteConfigurationRequest) throws SdkClientException, AmazonServiceException
AmazonS3
For more information on how to host a website on Amazon S3, see: http://docs.amazonwebservices.com/AmazonS3/latest/dev/WebsiteHosting. html.
This operation requires the S3:PutBucketWebsite
permission.
By default, only the bucket owner can configure the website attached to a
bucket. However, bucket owners can allow other users to set the website
configuration by writing a bucket policy granting them the
S3:PutBucketWebsite
permission.
setBucketWebsiteConfiguration
in interface AmazonS3
setBucketWebsiteConfigurationRequest
- The request object containing the name of the bucket whose
website configuration is being updated, and the new website
configuration values.SdkClientException
- If any errors are encountered on the client while making the
request or handling the response.AmazonServiceException
- If any errors occurred in Amazon S3 while processing the
request.public void deleteBucketWebsiteConfiguration(String bucketName) throws SdkClientException, AmazonServiceException
AmazonS3
For more information on how to host a website on Amazon S3, see: http://docs.amazonwebservices.com/AmazonS3/latest/dev/WebsiteHosting.html.
This operation requires the S3:DeleteBucketWebsite
permission. By default, only the bucket owner can delete the website
configuration attached to a bucket. However, bucket owners can grant
other users permission to delete the website configuration by writing a
bucket policy granting them the S3:DeleteBucketWebsite
permission.
deleteBucketWebsiteConfiguration
in interface AmazonS3
bucketName
- The name of the bucket whose website configuration is being
deleted.SdkClientException
- If any errors are encountered on the client while making the
request or handling the response.AmazonServiceException
- If any errors occurred in Amazon S3 while processing the
request.public void deleteBucketWebsiteConfiguration(DeleteBucketWebsiteConfigurationRequest deleteBucketWebsiteConfigurationRequest) throws SdkClientException, AmazonServiceException
AmazonS3
For more information on how to host a website on Amazon S3, see: http://docs.amazonwebservices.com/AmazonS3/latest/dev/WebsiteHosting. html.
This operation requires the S3:DeleteBucketWebsite
permission. By default, only the bucket owner can delete the website
configuration attached to a bucket. However, bucket owners can grant
other users permission to delete the website configuration by writing a
bucket policy granting them the S3:DeleteBucketWebsite
permission.
deleteBucketWebsiteConfiguration
in interface AmazonS3
deleteBucketWebsiteConfigurationRequest
- The request object specifying the name of the bucket whose
website configuration is to be deleted.SdkClientException
- If any errors are encountered on the client while making the
request or handling the response.AmazonServiceException
- If any errors occurred in Amazon S3 while processing the
request.public SetPublicAccessBlockResult setPublicAccessBlock(SetPublicAccessBlockRequest setPublicAccessBlockRequest)
AmazonS3
setPublicAccessBlock
in interface AmazonS3
setPublicAccessBlockRequest
- The request object for setting the buckets Public Access Block configuration.SetPublicAccessBlockResult
.public GetPublicAccessBlockResult getPublicAccessBlock(GetPublicAccessBlockRequest getPublicAccessBlockRequest)
AmazonS3
getPublicAccessBlock
in interface AmazonS3
getPublicAccessBlockRequest
- The request object for getting the buckets Public Access Block configuration.GetPublicAccessBlockResult
.public DeletePublicAccessBlockResult deletePublicAccessBlock(DeletePublicAccessBlockRequest deletePublicAccessBlockRequest)
AmazonS3
deletePublicAccessBlock
in interface AmazonS3
deletePublicAccessBlockRequest
- The request object for deleting the buckets Public Access Block configuration.DeletePublicAccessBlockResult
.public SetObjectLegalHoldResult setObjectLegalHold(SetObjectLegalHoldRequest setObjectLegalHoldRequest)
AmazonS3
setObjectLegalHold
in interface AmazonS3
setObjectLegalHoldRequest
- The request object for setting the object legal hold.SetObjectLegalHoldResult
.public GetObjectLegalHoldResult getObjectLegalHold(GetObjectLegalHoldRequest getObjectLegalHoldRequest)
AmazonS3
getObjectLegalHold
in interface AmazonS3
getObjectLegalHoldRequest
- The request object for getting an object legal hold status.GetObjectLegalHoldResult
.public SetObjectLockConfigurationResult setObjectLockConfiguration(SetObjectLockConfigurationRequest setObjectLockConfigurationRequest)
AmazonS3
setObjectLockConfiguration
in interface AmazonS3
setObjectLockConfigurationRequest
- The request object for setting the object lock configuration.SetObjectLockConfigurationResult
.public GetObjectLockConfigurationResult getObjectLockConfiguration(GetObjectLockConfigurationRequest getObjectLockConfigurationRequest)
AmazonS3
getObjectLockConfiguration
in interface AmazonS3
getObjectLockConfigurationRequest
- The request object for getting the object lock configuration.GetObjectLockConfigurationResult
.public SetObjectRetentionResult setObjectRetention(SetObjectRetentionRequest setObjectRetentionRequest)
AmazonS3
setObjectRetention
in interface AmazonS3
setObjectRetentionRequest
- The request object for setting the object retention.SetObjectRetentionResult
.public GetObjectRetentionResult getObjectRetention(GetObjectRetentionRequest getObjectRetentionRequest)
AmazonS3
getObjectRetention
in interface AmazonS3
getObjectRetentionRequest
- The request object for getting the object retention.GetObjectRetentionResult
.public URL generatePresignedUrl(String bucketName, String key, Date expiration) throws SdkClientException
AmazonS3
Returns a pre-signed URL for accessing an Amazon S3 resource.
Pre-signed URLs allow clients to form a URL for an Amazon S3 resource, and then sign it with the current Amazon Web Services security credentials. The pre-signed URL can be shared to other users, allowing access to the resource without providing an account's Amazon Web Services security credentials.
Pre-signed URLs are useful in many situations where Amazon Web Services security credentials aren't available from the client that needs to make the actual request to Amazon S3.
For example, an application may need remote users to upload files to the application owner's Amazon S3 bucket, but doesn't need to ship the Amazon Web Services security credentials with the application. A pre-signed URL to PUT an object into the owner's bucket can be generated from a remote location with the owner's Amazon Web Services security credentials, then the pre-signed URL can be passed to the end user's application to use.
If you are generating presigned url for Amazon Web Services KMS-encrypted objects, you need to specify the correct region of the bucket on your client and configure Amazon Web Services Signature Version 4 for added security. For more information on how to do this, see http://docs.aws.amazon.com/AmazonS3/latest/dev/UsingAWSSDK.html# specify-signature-version
generatePresignedUrl
in interface AmazonS3
bucketName
- The name of the bucket containing the desired object.key
- The key in the specified bucket under which the desired object
is stored.expiration
- The time at which the returned pre-signed URL will expire.SdkClientException
- If there were any problems pre-signing the request for the
specified S3 object.AmazonS3.generatePresignedUrl(String, String, Date, HttpMethod)
,
AmazonS3.generatePresignedUrl(GeneratePresignedUrlRequest)
public URL generatePresignedUrl(String bucketName, String key, Date expiration, HttpMethod method) throws SdkClientException
AmazonS3
Returns a pre-signed URL for accessing an Amazon S3 resource.
Pre-signed URLs allow clients to form a URL for an Amazon S3 resource, and then sign it with the current Amazon Web Services security credentials. The pre-signed URL can be shared to other users, allowing access to the resource without providing an account's Amazon Web Services security credentials.
Pre-signed URLs are useful in many situations where Amazon Web Services security credentials aren't available from the client that needs to make the actual request to Amazon S3.
For example, an application may need remote users to upload files to the application owner's Amazon S3 bucket, but doesn't need to ship the Amazon Web Services security credentials with the application. A pre-signed URL to PUT an object into the owner's bucket can be generated from a remote location with the owner's Amazon Web Services security credentials, then the pre-signed URL can be passed to the end user's application to use.
If you are generating presigned url for Amazon Web Services KMS-encrypted objects, you need to specify the correct region of the bucket on your client and configure Amazon Web Services Signature Version 4 for added security. For more information on how to do this, see http://docs.aws.amazon.com/AmazonS3/latest/dev/UsingAWSSDK.html# specify-signature-version
generatePresignedUrl
in interface AmazonS3
bucketName
- The name of the bucket containing the desired object.key
- The key in the specified bucket under which the desired object
is stored.expiration
- The time at which the returned pre-signed URL will expire.method
- The HTTP method verb to use for this URLSdkClientException
- If there were any problems pre-signing the request for the
specified S3 object.AmazonS3.generatePresignedUrl(String, String, Date)
,
AmazonS3.generatePresignedUrl(GeneratePresignedUrlRequest)
public URL generatePresignedUrl(GeneratePresignedUrlRequest req)
AmazonS3
Returns a pre-signed URL for accessing an Amazon S3 resource.
Pre-signed URLs allow clients to form a URL for an Amazon S3 resource, and then sign it with the current Amazon Web Services security credentials. The pre-signed URL can be shared to other users, allowing access to the resource without providing an account's Amazon Web Services security credentials.
Pre-signed URLs are useful in many situations where Amazon Web Services security credentials aren't available from the client that needs to make the actual request to Amazon S3.
For example, an application may need remote users to upload files to the application owner's Amazon S3 bucket, but doesn't need to ship the Amazon Web Services security credentials with the application. A pre-signed URL to PUT an object into the owner's bucket can be generated from a remote location with the owner's Amazon Web Services security credentials, then the pre-signed URL can be passed to the end user's application to use.
Note that presigned URLs cannot be used to upload an object with an attached policy, as described in this blog post. That method is only suitable for POSTs from HTML forms by browsers.
If you are generating presigned url for Amazon Web Services KMS-encrypted objects, you need to specify the correct region of the bucket on your client and configure Amazon Web Services Signature Version 4 for added security. For more information on how to do this, see http://docs.aws.amazon.com/AmazonS3/latest/dev/UsingAWSSDK.html# specify-signature-version
generatePresignedUrl
in interface AmazonS3
req
- The request object containing all the options for generating a
pre-signed URL (bucket name, key, expiration date, etc).AmazonS3.generatePresignedUrl(String, String, Date)
,
AmazonS3.generatePresignedUrl(String, String, Date, HttpMethod)
public void abortMultipartUpload(AbortMultipartUploadRequest abortMultipartUploadRequest) throws SdkClientException, AmazonServiceException
AmazonS3
abortMultipartUpload
in interface AmazonS3
abortMultipartUpload
in interface S3DirectSpi
abortMultipartUploadRequest
- The AbortMultipartUploadRequest object that specifies all the
parameters of this operation.SdkClientException
- If any errors are encountered in the client while making the
request or handling the response.AmazonServiceException
- If any errors occurred in Amazon S3 while processing the
request.public CompleteMultipartUploadResult completeMultipartUpload(CompleteMultipartUploadRequest completeMultipartUploadRequest) throws SdkClientException, AmazonServiceException
AmazonS3
Completes a multipart upload by assembling previously uploaded parts.
You first initiate the multipart upload and then upload all parts using the UploadPart operation. After
successfully uploading all relevant parts of an upload, you call this action to complete the upload. Upon
receiving this request, Amazon S3 concatenates all the parts in ascending order by part number to create a new
object. In the Complete Multipart Upload request, you must provide the parts list. You must ensure that the parts
list is complete. This action concatenates the parts that you provide in the list. For each part in the list, you
must provide the part number and the ETag
value, returned after that part was uploaded.
Processing of a Complete Multipart Upload request could take several minutes to complete. After Amazon S3 begins
processing the request, it sends an HTTP response header that specifies a 200 OK response. While processing is in
progress, Amazon S3 periodically sends white space characters to keep the connection from timing out. A request
could fail after the initial 200 OK response has been sent. This means that a 200 OK
response can
contain either a success or an error. If you call the S3 API directly, make sure to design your application to
parse the contents of the response and handle it appropriately. If you use Amazon Web Services SDKs, SDKs handle
this condition. The SDKs detect the embedded error and apply error handling per your configuration settings
(including automatically retrying the request as appropriate). If the condition persists, the SDKs throws an
exception (or, for the SDKs that don't use exceptions, they return the error).
Note that if CompleteMultipartUpload
fails, applications should be prepared to retry the failed
requests. For more information, see Amazon S3 Error Best
Practices.
You cannot use Content-Type: application/x-www-form-urlencoded
with Complete Multipart Upload
requests. Also, if you do not provide a Content-Type
header, CompleteMultipartUpload
returns a 200 OK response.
For more information about multipart uploads, see Uploading Objects Using Multipart Upload.
For information about permissions required to use the multipart upload API, see Multipart Upload and Permissions.
CompleteMultipartUpload
has the following special errors:
Error code: EntityTooSmall
Description: Your proposed upload is smaller than the minimum allowed object size. Each part must be at least 5 MB in size, except the last part.
400 Bad Request
Error code: InvalidPart
Description: One or more of the specified parts could not be found. The part might not have been uploaded, or the specified entity tag might not have matched the part's entity tag.
400 Bad Request
Error code: InvalidPartOrder
Description: The list of parts was not in ascending order. The parts list must be specified in order by part number.
400 Bad Request
Error code: NoSuchUpload
Description: The specified multipart upload does not exist. The upload ID might be invalid, or the multipart upload might have been aborted or completed.
404 Not Found
The following operations are related to CompleteMultipartUpload
:
completeMultipartUpload
in interface AmazonS3
completeMultipartUpload
in interface S3DirectSpi
completeMultipartUploadRequest
- The CompleteMultipartUploadRequest object that specifies all
the parameters of this operation.SdkClientException
- If any errors are encountered in the client while making the
request or handling the response.AmazonServiceException
- If any errors occurred in Amazon S3 while processing the
request.public InitiateMultipartUploadResult initiateMultipartUpload(InitiateMultipartUploadRequest initiateMultipartUploadRequest) throws SdkClientException, AmazonServiceException
AmazonS3
AmazonS3.uploadPart(UploadPartRequest)
requests. You also include this
upload ID in the final request to either complete, or abort the multipart
upload request.
Note: After you initiate a multipart upload and upload one or more parts, you must either complete or abort the multipart upload in order to stop getting charged for storage of the uploaded parts. Once you complete or abort the multipart upload Amazon S3 will release the stored parts and stop charging you for their storage.
If you are initiating a multipart upload for Amazon Web Services KMS-encrypted objects, you need to specify the correct region of the bucket on your client and configure Amazon Web Services Signature Version 4 for added security. For more information on how to do this, see http://docs.aws.amazon.com/AmazonS3/latest/dev/UsingAWSSDK.html# specify-signature-version
initiateMultipartUpload
in interface AmazonS3
initiateMultipartUpload
in interface S3DirectSpi
initiateMultipartUploadRequest
- The InitiateMultipartUploadRequest object that specifies all
the parameters of this operation.SdkClientException
- If any errors are encountered in the client while making the
request or handling the response.AmazonServiceException
- If any errors occurred in Amazon S3 while processing the
request.public MultipartUploadListing listMultipartUploads(ListMultipartUploadsRequest listMultipartUploadsRequest) throws SdkClientException, AmazonServiceException
AmazonS3
This operation returns at most 1,000 multipart uploads in the response by default. The number of multipart uploads can be further limited using the MaxUploads property on the request parameter. If there are additional multipart uploads that satisfy the list criteria, the response will contain an IsTruncated property with the value set to true. To list the additional multipart uploads use the KeyMarker and UploadIdMarker properties on the request parameters.
listMultipartUploads
in interface AmazonS3
listMultipartUploadsRequest
- The ListMultipartUploadsRequest object that specifies all the
parameters of this operation.SdkClientException
- If any errors are encountered in the client while making the
request or handling the response.AmazonServiceException
- If any errors occurred in Amazon S3 while processing the
request.public PartListing listParts(ListPartsRequest listPartsRequest) throws SdkClientException, AmazonServiceException
AmazonS3
This method must include the upload ID, returned by the
AmazonS3.initiateMultipartUpload(InitiateMultipartUploadRequest)
operation. This request returns a maximum of 1000 uploaded parts by
default. You can restrict the number of parts returned by specifying the
MaxParts property on the ListPartsRequest. If your multipart upload
consists of more parts than allowed in the ListParts response, the
response returns a IsTruncated field with value true, and a
NextPartNumberMarker property. In subsequent ListParts request you can
include the PartNumberMarker property and set its value to the
NextPartNumberMarker property value from the previous response.
listParts
in interface AmazonS3
listPartsRequest
- The ListPartsRequest object that specifies all the parameters
of this operation.SdkClientException
- If any errors are encountered in the client while making the
request or handling the response.AmazonServiceException
- If any errors occurred in Amazon S3 while processing the
request.public UploadPartResult uploadPart(UploadPartRequest uploadPartRequest) throws SdkClientException, AmazonServiceException
AmazonS3
Your UploadPart request must include an upload ID, a part number and part size. The upload ID is the ID returned by Amazon S3 in response to your Initiate Multipart Upload request. Part number can be any number between 1 and 10,000, inclusive. A part number uniquely identifies a part and also defines its position within the object being uploaded. If you upload a new part using the same part number that was specified in uploading a previous part, the previously uploaded part is overwritten.
For information about maximum and minimum part sizes and other multipart upload specifications, see Multipart upload limits in the Amazon S3 User Guide.
To ensure data is not corrupted traversing the network, specify the Content-MD5 header in the Upload Part request. Amazon S3 checks the part data against the provided MD5 value. If they do not match, Amazon S3 returns an error.
When you upload a part, the returned UploadPartResult contains an ETag property. You should record this ETag property value and the part number. After uploading all parts, you must send a CompleteMultipartUpload request. At that time Amazon S3 constructs a complete object by concatenating all the parts you uploaded, in ascending order based on the part numbers. The CompleteMultipartUpload request requires you to send all the part numbers and the corresponding ETag values.
Note: After you initiate a multipart upload and upload one or more parts, you must either complete or abort the multipart upload in order to stop getting charged for storage of the uploaded parts. Once you complete or abort the multipart upload Amazon S3 will release the stored parts and stop charging you for their storage.
If you are performing upload part for Amazon Web Services KMS-encrypted objects, you need to specify the correct region of the bucket on your client and configure Amazon Web Services Signature Version 4 for added security. For more information on how to do this, see http://docs.aws.amazon.com/AmazonS3/latest/dev/UsingAWSSDK.html# specify-signature-version
When supplying an InputStream
using UploadPartRequest.withInputStream(InputStream)
or UploadPartRequest.setInputStream(InputStream)
, the stream will only be
closed by the client if UploadPartRequest.isLastPart()
is true
. If this is not the last part, the stream will be left open.
uploadPart
in interface AmazonS3
uploadPart
in interface S3DirectSpi
uploadPartRequest
- The UploadPartRequest object that specifies all the parameters
of this operation.SdkClientException
- If any errors are encountered in the client while making the
request or handling the response.AmazonServiceException
- If any errors occurred in Amazon S3 while processing the
request.public S3ResponseMetadata getCachedResponseMetadata(AmazonWebServiceRequest request)
AmazonS3
Response metadata is only cached for a limited period of time. Use this method to retrieve the response metadata as soon as possible after executing a request.
getCachedResponseMetadata
in interface AmazonS3
request
- The originally executed request.null
if none is available.public void restoreObject(RestoreObjectRequest restoreObjectRequest) throws AmazonServiceException
AmazonS3
restoreObject
in interface AmazonS3
restoreObjectRequest
- The request object containing all the options for restoring an
Amazon S3 object.AmazonServiceException
- If any errors occurred in Amazon S3 while processing the
request.AmazonS3Client.restoreObject(String, String, int)
public void restoreObject(String bucketName, String key, int expirationInDays) throws AmazonServiceException
AmazonS3
restoreObject
in interface AmazonS3
bucketName
- The name of an existing bucket.key
- The key under which to store the specified file.expirationInDays
- The number of days after which the object will expire.AmazonServiceException
- If any errors occurred in Amazon S3 while processing the
request.AmazonS3Client#restoreObjectV2(RestoreObjectRequest)
public PutObjectResult putObject(String bucketName, String key, String content) throws AmazonServiceException, SdkClientException
AmazonS3
Encodes a String into the contents of an S3 object.
String will be encoded to bytes with UTF-8 encoding.
putObject
in interface AmazonS3
bucketName
- The name of the bucket to place the new object in.key
- The key of the object to create.content
- The String to encodeAmazonServiceException
SdkClientException
protected Signer createSigner(Request<?> request, String bucketName, String key)
protected Signer createSigner(Request<?> request, String bucketName, String key, boolean isAdditionalHeadRequestToFindRegion)
protected <T> void presignRequest(Request<T> request, HttpMethod methodName, String bucketName, String key, Date expiration, String subResource)
request
- The request to sign.methodName
- The HTTP method (GET, PUT, DELETE, HEAD) for the specified
request.bucketName
- The name of the bucket involved in the request. If the request
is not an operation on a bucket this parameter should be null.key
- The object key involved in the request. If the request is not
an operation on an object, this parameter should be null.expiration
- The time at which the signed request is no longer valid, and
will stop working.subResource
- The optional sub-resource being requested as part of the
request (e.g. "location", "acl", "logging", or "torrent").protected static void populateRequestMetadata(Request<?> request, ObjectMetadata metadata)
Populates the specified request object with the appropriate headers from
the ObjectMetadata
object.
request
- The request to populate with headers.metadata
- The metadata containing the header information to include in
the request.protected static void populateRequesterPaysHeader(Request<?> request, boolean isRequesterPays)
Populate the specified request with Constants.REQUESTER_PAYS
to header Headers.REQUESTER_PAYS_HEADER
,
if isRequesterPays is true.
request
- The specified request to populate.isRequesterPays
- The flag whether to populate the header or not.public String getResourceUrl(String bucketName, String key)
public URL getUrl(String bucketName, String key)
AmazonS3
If the object identified by the given bucket and key has public read
permissions (ex: CannedAccessControlList.PublicRead
), then this
URL can be directly accessed to retrieve the object's data.
public Region getRegion()
AmazonS3
public String getRegionName()
AmazonS3
getRegionName
in interface AmazonS3
protected <X extends AmazonWebServiceRequest> Request<X> createRequest(String bucketName, String key, X originalRequest, HttpMethodName httpMethod)
bucketName
- An optional parameter indicating the name of the bucket
containing the resource involved in the request.key
- An optional parameter indicating the key under which the
desired resource is stored in the specified bucket.originalRequest
- The original request, as created by the user.httpMethod
- The HTTP method to use when sending the request.protected <X extends AmazonWebServiceRequest> Request<X> createRequest(String bucketName, String key, X originalRequest, HttpMethodName httpMethod, URI endpoint)
public PresignedUrlDownloadResult download(PresignedUrlDownloadRequest presignedUrlDownloadRequest) throws SdkClientException
AmazonS3
Gets the object stored in Amazon S3 using a presigned url.
The result contains S3Object
representing the downloaded object.
Be extremely careful when using this method; the returned Amazon S3
object contains a direct stream of data from the HTTP connection. The
underlying HTTP connection cannot be reused until the user finishes
reading the data and closes the stream. Also note that if not all data
is read from the stream then the SDK will abort the underlying connection,
this may have a negative impact on performance. Therefore:
PresignedUrlDownloadRequest.setRange(long, long)
to request only the bytes you need)download
in interface AmazonS3
presignedUrlDownloadRequest
- The request object to download the object.SdkClientException
- If any errors are encountered in the client while making the
request or handling the response.AmazonServiceException
- If any errors occurred in Amazon S3 while processing the
request.public void download(PresignedUrlDownloadRequest presignedUrlDownloadRequest, File destinationFile) throws SdkClientException
AmazonS3
Gets the object stored in Amazon S3 using a presigned url.
The result contains S3Object
representing the downloaded object.
Be extremely careful when using this method; the returned Amazon S3
object contains a direct stream of data from the HTTP connection. The
underlying HTTP connection cannot be reused until the user finishes
reading the data and closes the stream. Also note that if not all data
is read from the stream then the SDK will abort the underlying connection,
this may have a negative impact on performance. Therefore:
PresignedUrlDownloadRequest.setRange(long, long)
to request only the bytes you need)download
in interface AmazonS3
presignedUrlDownloadRequest
- The request object to download the object.destinationFile
- Indicates the file (which might already exist) where
to save the object content being downloading from Amazon S3.SdkClientException
- If any errors are encountered in the client while making the
request or handling the response.AmazonServiceException
- If any errors occurred in Amazon S3 while processing the
request.public PresignedUrlUploadResult upload(PresignedUrlUploadRequest presignedUrlUploadRequest)
AmazonS3
Uploads a new object into S3 using the given presigned url.
Depending on whether a file or input stream is being uploaded, this request has slightly different behavior.When uploading a file:
PresignedUrlUploadRequest.setMetadata(ObjectMetadata)
or
AmazonWebServiceRequest.putCustomRequestHeader(String, String)
When uploading directly from an input stream, content length must be specified before data can be uploaded to Amazon S3. If not provided, the library will have to buffer the contents of the input stream in order to calculate it. Amazon S3 explicitly requires that the content length be sent in the request headers before any of the data is sent.
Amazon S3 is a distributed system. If it receives multiple write requests for the same object simultaneously, it overwrites all but the last object written. To prevent objects from being deleted or overwritten, you can use Amazon S3 Object Lock.
upload
in interface AmazonS3
presignedUrlUploadRequest
- The request object containing all the parameters to upload a
new object to Amazon S3.PresignedUrlUploadResult
object containing the information
returned by Amazon S3 for the newly created object.protected final SignerProvider createSignerProvider(Signer signer)
createSignerProvider
in class AmazonWebServiceClient
protected final InitiateMultipartUploadRequest newInitiateMultipartUploadRequest(UploadObjectRequest req)
public void setBucketReplicationConfiguration(String bucketName, BucketReplicationConfiguration configuration) throws AmazonServiceException, SdkClientException
AmazonS3
Creates a replication configuration or replaces an existing one. For more information, see Replication in the Amazon S3 User Guide.
Specify the replication configuration in the request body. In the replication configuration, you provide the name of the destination bucket or buckets where you want Amazon S3 to replicate objects, the IAM role that Amazon S3 can assume to replicate objects on your behalf, and other relevant information.
A replication configuration must include at least one rule, and can contain a maximum of 1,000. Each rule identifies a subset of objects to replicate by filtering the objects in the source bucket. To choose additional subsets of objects to replicate, add a rule for each subset.
To specify a subset of the objects in the source bucket to apply a replication rule to, add the Filter element as
a child of the Rule element. You can filter objects based on an object key prefix, one or more object tags, or
both. When you add the Filter element in the configuration, you must also add the following elements:
DeleteMarkerReplication
, Status
, and Priority
.
If you are using an earlier version of the replication configuration, Amazon S3 handles replication of delete markers differently. For more information, see Backward Compatibility.
For information about enabling versioning on a bucket, see Using Versioning.
Handling Replication of Encrypted Objects
By default, Amazon S3 doesn't replicate objects that are stored at rest using server-side encryption with CMKs
stored in Amazon Web Services KMS. To replicate Amazon Web Services KMS-encrypted objects, add the following:
SourceSelectionCriteria
, SseKmsEncryptedObjects
, Status
,
EncryptionConfiguration
, and ReplicaKmsKeyID
. For information about replication
configuration, see Replicating
Objects Created with SSE Using CMKs stored in Amazon Web Services KMS.
For information on PutBucketReplication
errors, see List of
replication-related error codes
Permissions
To create a PutBucketReplication
request, you must have s3:PutReplicationConfiguration
permissions for the bucket.
By default, a resource owner, in this case the Amazon Web Services account that created the bucket, can perform this operation. The resource owner can also grant others permissions to perform the operation. For more information about permissions, see Specifying Permissions in a Policy and Managing Access Permissions to Your Amazon S3 Resources.
To perform this operation, the user or role performing the action must have the iam:PassRole permission.
The following operations are related to PutBucketReplication
:
setBucketReplicationConfiguration
in interface AmazonS3
AmazonServiceException
SdkClientException
AmazonS3.setBucketReplicationConfiguration(SetBucketReplicationConfigurationRequest)
,
AmazonS3.getBucketReplicationConfiguration(String)
,
AmazonS3.deleteBucketReplicationConfiguration(String)
public void setBucketReplicationConfiguration(SetBucketReplicationConfigurationRequest setBucketReplicationConfigurationRequest) throws AmazonServiceException, SdkClientException
AmazonS3
Creates a replication configuration or replaces an existing one. For more information, see Replication in the Amazon S3 User Guide.
Specify the replication configuration in the request body. In the replication configuration, you provide the name of the destination bucket or buckets where you want Amazon S3 to replicate objects, the IAM role that Amazon S3 can assume to replicate objects on your behalf, and other relevant information.
A replication configuration must include at least one rule, and can contain a maximum of 1,000. Each rule identifies a subset of objects to replicate by filtering the objects in the source bucket. To choose additional subsets of objects to replicate, add a rule for each subset.
To specify a subset of the objects in the source bucket to apply a replication rule to, add the Filter element as
a child of the Rule element. You can filter objects based on an object key prefix, one or more object tags, or
both. When you add the Filter element in the configuration, you must also add the following elements:
DeleteMarkerReplication
, Status
, and Priority
.
If you are using an earlier version of the replication configuration, Amazon S3 handles replication of delete markers differently. For more information, see Backward Compatibility.
For information about enabling versioning on a bucket, see Using Versioning.
Handling Replication of Encrypted Objects
By default, Amazon S3 doesn't replicate objects that are stored at rest using server-side encryption with CMKs
stored in Amazon Web Services KMS. To replicate Amazon Web Services KMS-encrypted objects, add the following:
SourceSelectionCriteria
, SseKmsEncryptedObjects
, Status
,
EncryptionConfiguration
, and ReplicaKmsKeyID
. For information about replication
configuration, see Replicating
Objects Created with SSE Using CMKs stored in Amazon Web Services KMS.
For information on PutBucketReplication
errors, see List of
replication-related error codes
Permissions
To create a PutBucketReplication
request, you must have s3:PutReplicationConfiguration
permissions for the bucket.
By default, a resource owner, in this case the Amazon Web Services account that created the bucket, can perform this operation. The resource owner can also grant others permissions to perform the operation. For more information about permissions, see Specifying Permissions in a Policy and Managing Access Permissions to Your Amazon S3 Resources.
To perform this operation, the user or role performing the action must have the iam:PassRole permission.
The following operations are related to PutBucketReplication
:
setBucketReplicationConfiguration
in interface AmazonS3
AmazonServiceException
SdkClientException
AmazonS3.setBucketReplicationConfiguration(String, BucketReplicationConfiguration)
,
AmazonS3.getBucketReplicationConfiguration(String)
,
AmazonS3.deleteBucketReplicationConfiguration(String)
public BucketReplicationConfiguration getBucketReplicationConfiguration(String bucketName) throws AmazonServiceException, SdkClientException
AmazonS3
getBucketReplicationConfiguration
in interface AmazonS3
bucketName
- The bucket name for which the replication configuration is to
be retrieved.AmazonServiceException
- If any errors occurred in Amazon S3 while processing the
request.SdkClientException
- If any errors are encountered in the client while making the
request or handling the response.AmazonS3.setBucketReplicationConfiguration(String,
BucketReplicationConfiguration)
,
AmazonS3.deleteBucketReplicationConfiguration(String)
public BucketReplicationConfiguration getBucketReplicationConfiguration(GetBucketReplicationConfigurationRequest getBucketReplicationConfigurationRequest) throws AmazonServiceException, SdkClientException
AmazonS3
getBucketReplicationConfiguration
in interface AmazonS3
getBucketReplicationConfigurationRequest
- The request object for retrieving the bucket replication configuration.AmazonServiceException
- If any errors occurred in Amazon S3 while processing the
request.SdkClientException
- If any errors are encountered in the client while making the
request or handling the response.AmazonS3.setBucketReplicationConfiguration(String,
BucketReplicationConfiguration)
,
AmazonS3.deleteBucketReplicationConfiguration(String)
public void deleteBucketReplicationConfiguration(String bucketName) throws AmazonServiceException, SdkClientException
AmazonS3
deleteBucketReplicationConfiguration
in interface AmazonS3
bucketName
- The bucket name for which the replication configuration is to
be deleted.AmazonServiceException
- If any errors occurred in Amazon S3 while processing the
request.SdkClientException
- If any errors are encountered in the client while making the
request or handling the response.AmazonS3.setBucketReplicationConfiguration(String,
BucketReplicationConfiguration)
,
AmazonS3.getBucketReplicationConfiguration(String)
,
AmazonS3.deleteBucketReplicationConfiguration(DeleteBucketReplicationConfigurationRequest)
public void deleteBucketReplicationConfiguration(DeleteBucketReplicationConfigurationRequest deleteBucketReplicationConfigurationRequest) throws AmazonServiceException, SdkClientException
AmazonS3
deleteBucketReplicationConfiguration
in interface AmazonS3
deleteBucketReplicationConfigurationRequest
- The request object for delete bucket replication
configuration.AmazonServiceException
- If any errors occurred in Amazon S3 while processing the
request.SdkClientException
- If any errors are encountered in the client while making the
request or handling the response.AmazonS3.setBucketReplicationConfiguration(String,
BucketReplicationConfiguration)
,
AmazonS3.getBucketReplicationConfiguration(String)
,
AmazonS3.deleteBucketReplicationConfiguration(String)
public AmazonS3Waiters waiters()
protected Request<CreateBucketRequest> addIAMHeaders(Request<CreateBucketRequest> request, CreateBucketRequest createBucketRequest)
request
- createBucketRequest
- public void setBucketProtectionConfiguration(SetBucketProtectionConfigurationRequest setBucketProtectionConfigurationRequest) throws SdkClientException, AmazonServiceException
AmazonS3
setBucketProtectionConfiguration
in interface AmazonS3
setBucketProtectionConfigurationRequest
- The request object containing all options for setting the
bucket protection configurationSdkClientException
- If any errors are encountered in the client while making the
request or handling the response.AmazonServiceException
- If any errors occurred in Amazon S3 while processing the
request.public void setBucketProtection(String bucketName, BucketProtectionConfiguration protectionConfiguration) throws SdkClientException, AmazonServiceException
setBucketProtection
in interface AmazonS3
bucketName
- The name of the bucket for which to set protection configurationSdkClientException
- If any errors are encountered in the client while making the
request or handling the response.AmazonServiceException
- If any errors occurred in Amazon S3 while processing the
request.public BucketProtectionConfiguration getBucketProtection(String bucketName) throws SdkClientException, AmazonServiceException
AmazonS3
getBucketProtection
in interface AmazonS3
bucketName
- The bucket whose protection configuration will be retrieved.SdkClientException
- If any errors are encountered in the client while making the
request or handling the response.AmazonServiceException
- If any errors occurred in Amazon S3 while processing the
request.public BucketProtectionConfiguration getBucketProtectionConfiguration(GetBucketProtectionConfigurationRequest getBucketProtectionRequest) throws SdkClientException, AmazonServiceException
getBucketProtectionConfiguration
in interface AmazonS3
getBucketProtectionRequest
- The request object for retrieving the bucket protection configuration.SdkClientException
- If any errors are encountered in the client while making the
request or handling the response.AmazonServiceException
- If any errors occurred in Amazon S3 while processing the
request.public void addLegalHold(String bucketName, String key, String legalHoldId) throws SdkClientException, AmazonServiceException
AmazonS3
addLegalHold
in interface AmazonS3
bucketName
- The name of the Amazon S3 bucket containing the object to
add a legal hold to.key
- The key of the object to add a legal hold to.legalHoldId
- The id of the legal hold to add.SdkClientException
- If any errors are encountered in the client while making the
request or handling the response.AmazonServiceException
- If any errors occurred in Amazon S3 while processing the
request.public void addLegalHold(AddLegalHoldRequest addLegalHoldRequest) throws SdkClientException, AmazonServiceException
AmazonS3
addLegalHold
in interface AmazonS3
addLegalHoldRequest
- The request object containing all options for adding a legal hold to an
object.SdkClientException
- If any errors are encountered in the client while making the
request or handling the response.AmazonServiceException
- If any errors occurred in Amazon S3 while processing the
request.AmazonS3Client.addLegalHold(String, String, String)
public ListLegalHoldsResult listLegalHolds(String bucketName, String key) throws SdkClientException, AmazonServiceException
AmazonS3
listLegalHolds
in interface AmazonS3
bucketName
- The name of the bucket containing the object.key
- The name of the object to list legal holds for.SdkClientException
- If any errors are encountered in the client while making the
request or handling the response.AmazonServiceException
- If any errors occurred in Amazon S3 while processing the
request.public ListLegalHoldsResult listLegalHolds(ListLegalHoldsRequest listLegalHoldsRequest) throws SdkClientException, AmazonServiceException
AmazonS3
listLegalHolds
in interface AmazonS3
listLegalHoldsRequest
- The request object containing all options for listing the
legal holds for a specified object in a specified bucket.SdkClientException
- If any errors are encountered in the client while making the
request or handling the response.AmazonServiceException
- If any errors occurred in Amazon S3 while processing the
request.public void deleteLegalHold(String bucketName, String key, String legalHoldId) throws SdkClientException, AmazonServiceException
AmazonS3
deleteLegalHold
in interface AmazonS3
bucketName
- The name of the Amazon S3 bucket containing the object to
delete a legal hold from.key
- The key of the object to delete a legal hold from.legalHoldId
- The id of the legal hold to delete.SdkClientException
- If any errors are encountered in the client while making the
request or handling the response.AmazonServiceException
- If any errors occurred in Amazon S3 while processing the
request.public void deleteLegalHold(DeleteLegalHoldRequest deleteLegalHoldRequest) throws SdkClientException, AmazonServiceException
AmazonS3
deleteLegalHold
in interface AmazonS3
deleteLegalHoldRequest
- The request object containing all options for deleting a legal hold from an
object.SdkClientException
- If any errors are encountered in the client while making the
request or handling the response.AmazonServiceException
- If any errors occurred in Amazon S3 while processing the
request.AmazonS3Client.deleteLegalHold(String, String, String)
public void extendObjectRetention(String bucketName, String key, Long additionalRetentionPeriod, Long extendRetentionFromCurrentTime, Date newRetentionExpirationDate, Long newRetentionPeriod) throws SdkClientException, AmazonServiceException
AmazonS3
extendObjectRetention
in interface AmazonS3
bucketName
- The name of the Amazon S3 bucket containing the object to
delete a legal hold from.key
- The key of the object to delete a legal hold from.SdkClientException
- If any errors are encountered in the client while making the
request or handling the response.AmazonServiceException
- If any errors occurred in Amazon S3 while processing the
request.public void extendObjectRetention(ExtendObjectRetentionRequest extendObjectRetentionRequest) throws SdkClientException, AmazonServiceException
AmazonS3
extendObjectRetention
in interface AmazonS3
extendObjectRetentionRequest
- The request object containing all options for extending the retention period
of a protected object.SdkClientException
- If any errors are encountered in the client while making the
request or handling the response.AmazonServiceException
- If any errors occurred in Amazon S3 while processing the
request.AmazonS3Client.deleteLegalHold(String, String, String)
public FASPConnectionInfo getBucketFaspConnectionInfo(String bucketName) throws SdkClientException, AmazonServiceException
AmazonS3
Gets the FASP Connection Info for a particular bucket.
Each bucket COS has associated FASP connection information this will return Access Key & Secret, along with an ATS Endpoint
getBucketFaspConnectionInfo
in interface AmazonS3
bucketName
- The name of the bucket whose FASPConnectionInfo is being retrieved. FASPConnectionInfo
for the specified S3 bucket.SdkClientException
- If any errors are encountered in the client while making the
request or handling the response.AmazonServiceException
- If any errors occurred in Amazon S3 while processing the
request.public FASPConnectionInfo getBucketFaspConnectionInfo(GetBucketFaspConnectionInfoRequest getBucketFaspConnectionInfoRequest) throws SdkClientException, AmazonServiceException
AmazonS3
Gets the FASP Connection Info for a particular bucket.
Each bucket COS has associated FASP connection information this will return Access Key & Secret, along with an ATS Endpoint
getBucketFaspConnectionInfo
in interface AmazonS3
getBucketFaspConnectionInfoRequest
- The request containing the name of the bucket whose FASPConnectionInfo is
being retrieved. FASPConnectionInfo
for the specified S3 bucket.SdkClientException
- If any errors are encountered in the client while making the
request or handling the response.AmazonServiceException
- If any errors occurred in Amazon S3 while processing the
request.Copyright © 2024. All rights reserved.