This page describes the parameters and results for the operations of the Amazon Simple Storage Service (2006-03-01), and shows how to use the Aws\S3\S3Client object to call the described operations. This documentation is specific to the 2006-03-01 API version of the service.
Operation Summary
Each of the following operations can be created from a client using $client->getCommand('CommandName'), where “CommandName” is the name of one of the following operations. Note: a command is a value that encapsulates an operation and the parameters used to create an HTTP request.
You can also create and send a command immediately using the magic methods available on a client object: $client->commandName(/* parameters */). You can send the command asynchronously (returning a promise) by appending the word “Async” to the operation name: $client->commandNameAsync(/* parameters */).
- AbortMultipartUpload ( array $params = [] )
This action aborts a multipart upload.
- CompleteMultipartUpload ( array $params = [] )
Completes a multipart upload by assembling previously uploaded parts.
- CopyObject ( array $params = [] )
Creates a copy of an object that is already stored in Amazon S3.
- CreateBucket ( array $params = [] )
Creates a new S3 bucket.
- CreateMultipartUpload ( array $params = [] )
This action initiates a multipart upload and returns an upload ID.
- DeleteBucket ( array $params = [] )
Deletes the S3 bucket.
- DeleteBucketAnalyticsConfiguration ( array $params = [] )
Deletes an analytics configuration for the bucket (specified by the analytics configuration ID).
- DeleteBucketCors ( array $params = [] )
Deletes the cors configuration information set for the bucket.
- DeleteBucketEncryption ( array $params = [] )
This implementation of the DELETE action removes default encryption from the bucket.
- DeleteBucketIntelligentTieringConfiguration ( array $params = [] )
Deletes the S3 Intelligent-Tiering configuration from the specified bucket.
- DeleteBucketInventoryConfiguration ( array $params = [] )
Deletes an inventory configuration (identified by the inventory ID) from the bucket.
- DeleteBucketLifecycle ( array $params = [] )
Deletes the lifecycle configuration from the specified bucket.
- DeleteBucketMetricsConfiguration ( array $params = [] )
Deletes a metrics configuration for the Amazon CloudWatch request metrics (specified by the metrics configuration ID) from the bucket.
- DeleteBucketOwnershipControls ( array $params = [] )
Removes OwnershipControls for an Amazon S3 bucket.
- DeleteBucketPolicy ( array $params = [] )
This implementation of the DELETE action uses the policy subresource to delete the policy of a specified bucket.
- DeleteBucketReplication ( array $params = [] )
Deletes the replication configuration from the bucket.
- DeleteBucketTagging ( array $params = [] )
Deletes the tags from the bucket.
- DeleteBucketWebsite ( array $params = [] )
This action removes the website configuration for a bucket.
- DeleteObject ( array $params = [] )
Removes the null version (if there is one) of an object and inserts a delete marker, which becomes the latest version of the object.
- DeleteObjectTagging ( array $params = [] )
Removes the entire tag set from the specified object.
- DeleteObjects ( array $params = [] )
This action enables you to delete multiple objects from a bucket using a single HTTP request.
- DeletePublicAccessBlock ( array $params = [] )
Removes the PublicAccessBlock configuration for an Amazon S3 bucket.
- GetBucketAccelerateConfiguration ( array $params = [] )
This implementation of the GET action uses the accelerate subresource to return the Transfer Acceleration state of a bucket, which is either Enabled or Suspended.
- GetBucketAcl ( array $params = [] )
This implementation of the GET action uses the acl subresource to return the access control list (ACL) of a bucket.
- GetBucketAnalyticsConfiguration ( array $params = [] )
This implementation of the GET action returns an analytics configuration (identified by the analytics configuration ID) from the bucket.
- GetBucketCors ( array $params = [] )
Returns the cors configuration information set for the bucket.
- GetBucketEncryption ( array $params = [] )
Returns the default encryption configuration for an Amazon S3 bucket.
- GetBucketIntelligentTieringConfiguration ( array $params = [] )
Gets the S3 Intelligent-Tiering configuration from the specified bucket.
- GetBucketInventoryConfiguration ( array $params = [] )
Returns an inventory configuration (identified by the inventory configuration ID) from the bucket.
- GetBucketLifecycle ( array $params = [] )
For an updated version of this API, see GetBucketLifecycleConfiguration.
- GetBucketLifecycleConfiguration ( array $params = [] )
Bucket lifecycle configuration now supports specifying a lifecycle rule using an object key name prefix, one or more object tags, or a combination of both.
- GetBucketLocation ( array $params = [] )
Returns the Region the bucket resides in.
- GetBucketLogging ( array $params = [] )
Returns the logging status of a bucket and the permissions users have to view and modify that status.
- GetBucketMetricsConfiguration ( array $params = [] )
Gets a metrics configuration (specified by the metrics configuration ID) from the bucket.
- GetBucketNotification ( array $params = [] )
No longer used, see GetBucketNotificationConfiguration.
- GetBucketNotificationConfiguration ( array $params = [] )
Returns the notification configuration of a bucket.
- GetBucketOwnershipControls ( array $params = [] )
Retrieves OwnershipControls for an Amazon S3 bucket.
- GetBucketPolicy ( array $params = [] )
Returns the policy of a specified bucket.
- GetBucketPolicyStatus ( array $params = [] )
Retrieves the policy status for an Amazon S3 bucket, indicating whether the bucket is public.
- GetBucketReplication ( array $params = [] )
Returns the replication configuration of a bucket.
- GetBucketRequestPayment ( array $params = [] )
Returns the request payment configuration of a bucket.
- GetBucketTagging ( array $params = [] )
Returns the tag set associated with the bucket.
- GetBucketVersioning ( array $params = [] )
Returns the versioning state of a bucket.
- GetBucketWebsite ( array $params = [] )
Returns the website configuration for a bucket.
- GetObject ( array $params = [] )
Retrieves objects from Amazon S3.
- GetObjectAcl ( array $params = [] )
Returns the access control list (ACL) of an object.
- GetObjectLegalHold ( array $params = [] )
Gets an object’s current Legal Hold status.
- GetObjectLockConfiguration ( array $params = [] )
Gets the Object Lock configuration for a bucket.
- GetObjectRetention ( array $params = [] )
Retrieves an object’s retention settings.
- GetObjectTagging ( array $params = [] )
Returns the tag-set of an object.
- GetObjectTorrent ( array $params = [] )
Returns torrent files from a bucket.
- GetPublicAccessBlock ( array $params = [] )
Retrieves the PublicAccessBlock configuration for an Amazon S3 bucket.
- HeadBucket ( array $params = [] )
This action is useful to determine if a bucket exists and you have permission to access it.
- HeadObject ( array $params = [] )
The HEAD action retrieves metadata from an object without returning the object itself.
- ListBucketAnalyticsConfigurations ( array $params = [] )
Lists the analytics configurations for the bucket.
- ListBucketIntelligentTieringConfigurations ( array $params = [] )
Lists the S3 Intelligent-Tiering configuration from the specified bucket.
- ListBucketInventoryConfigurations ( array $params = [] )
Returns a list of inventory configurations for the bucket.
- ListBucketMetricsConfigurations ( array $params = [] )
Lists the metrics configurations for the bucket.
- ListBuckets ( array $params = [] )
Returns a list of all buckets owned by the authenticated sender of the request.
- ListMultipartUploads ( array $params = [] )
This action lists in-progress multipart uploads.
- ListObjectVersions ( array $params = [] )
Returns metadata about all versions of the objects in a bucket.
- ListObjects ( array $params = [] )
Returns some or all (up to 1,000) of the objects in a bucket.
- ListObjectsV2 ( array $params = [] )
Returns some or all (up to 1,000) of the objects in a bucket with each request.
- ListParts ( array $params = [] )
Lists the parts that have been uploaded for a specific multipart upload.
- PutBucketAccelerateConfiguration ( array $params = [] )
Sets the accelerate configuration of an existing bucket.
- PutBucketAcl ( array $params = [] )
Sets the permissions on an existing bucket using access control lists (ACL).
- PutBucketAnalyticsConfiguration ( array $params = [] )
Sets an analytics configuration for the bucket (specified by the analytics configuration ID).
- PutBucketCors ( array $params = [] )
Sets the cors configuration for your bucket.
- PutBucketEncryption ( array $params = [] )
This action uses the encryption subresource to configure default encryption and Amazon S3 Bucket Key for an existing bucket.
- PutBucketIntelligentTieringConfiguration ( array $params = [] )
Puts a S3 Intelligent-Tiering configuration to the specified bucket.
- PutBucketInventoryConfiguration ( array $params = [] )
This implementation of the PUT action adds an inventory configuration (identified by the inventory ID) to the bucket.
- PutBucketLifecycle ( array $params = [] )
For an updated version of this API, see PutBucketLifecycleConfiguration.
- PutBucketLifecycleConfiguration ( array $params = [] )
Creates a new lifecycle configuration for the bucket or replaces an existing lifecycle configuration.
- PutBucketLogging ( array $params = [] )
Set the logging parameters for a bucket and to specify permissions for who can view and modify the logging parameters.
- PutBucketMetricsConfiguration ( array $params = [] )
Sets a metrics configuration (specified by the metrics configuration ID) for the bucket.
- PutBucketNotification ( array $params = [] )
No longer used, see the PutBucketNotificationConfiguration operation.
- PutBucketNotificationConfiguration ( array $params = [] )
Enables notifications of specified events for a bucket.
- PutBucketOwnershipControls ( array $params = [] )
Creates or modifies OwnershipControls for an Amazon S3 bucket.
- PutBucketPolicy ( array $params = [] )
Applies an Amazon S3 bucket policy to an Amazon S3 bucket.
- PutBucketReplication ( array $params = [] )
Creates a replication configuration or replaces an existing one.
- PutBucketRequestPayment ( array $params = [] )
Sets the request payment configuration for a bucket.
- PutBucketTagging ( array $params = [] )
Sets the tags for a bucket.
- PutBucketVersioning ( array $params = [] )
Sets the versioning state of an existing bucket.
- PutBucketWebsite ( array $params = [] )
Sets the configuration of the website that is specified in the website subresource.
- PutObject ( array $params = [] )
Adds an object to a bucket.
- PutObjectAcl ( array $params = [] )
Uses the acl subresource to set the access control list (ACL) permissions for a new or existing object in an S3 bucket.
- PutObjectLegalHold ( array $params = [] )
Applies a Legal Hold configuration to the specified object.
- PutObjectLockConfiguration ( array $params = [] )
Places an Object Lock configuration on the specified bucket.
- PutObjectRetention ( array $params = [] )
Places an Object Retention configuration on an object.
- PutObjectTagging ( array $params = [] )
Sets the supplied tag-set to an object that already exists in a bucket.
- PutPublicAccessBlock ( array $params = [] )
Creates or modifies the PublicAccessBlock configuration for an Amazon S3 bucket.
- RestoreObject ( array $params = [] )
Restores an archived copy of an object back into Amazon S3 This action is not supported by Amazon S3 on Outposts.
- SelectObjectContent ( array $params = [] )
This action filters the contents of an Amazon S3 object based on a simple structured query language (SQL) statement.
- UploadPart ( array $params = [] )
Uploads a part in a multipart upload.
- UploadPartCopy ( array $params = [] )
Uploads a part by copying data from an existing object as data source.
- WriteGetObjectResponse ( array $params = [] )
Passes transformed objects to a GetObject operation when using Object Lambda access points.
Paginators
Paginators handle automatically iterating over paginated API results. Paginators are associated with specific API operations, and they accept the parameters that the corresponding API operation accepts. You can get a paginator from a client class using getPaginator($paginatorName, $operationParameters). This client supports the following paginators:
Waiters
Waiters allow you to poll a resource until it enters into a desired state. A waiter has a name used to describe what it does, and is associated with an API operation. When creating a waiter, you can provide the API operation parameters associated with the corresponding operation. Waiters can be accessed using the getWaiter($waiterName, $operationParameters) method of a client object. This client supports the following waiters:
| Waiter name | API Operation | Delay | Max Attempts |
|---|---|---|---|
| BucketExists | HeadBucket | 5 | 20 |
| BucketNotExists | HeadBucket | 5 | 20 |
| ObjectExists | HeadObject | 5 | 20 |
| ObjectNotExists | HeadObject | 5 | 20 |
Operations
AbortMultipartUpload
$result = $client->abortMultipartUpload([/* ... */]); $promise = $client->abortMultipartUploadAsync([/* ... */]);
This action aborts a multipart upload. After a multipart upload is aborted, no additional parts can be uploaded using that upload ID. The storage consumed by any previously uploaded parts will be freed. However, if any part uploads are currently in progress, those part uploads might or might not succeed. As a result, it might be necessary to abort a given multipart upload multiple times in order to completely free all storage consumed by all parts.
To verify that all parts have been removed, so you don’t get charged for the part storage, you should call the ListParts action and ensure that the parts list is empty.
For information about permissions required to use the multipart upload, see Multipart Upload and Permissions.
The following operations are related to AbortMultipartUpload:
Parameter Syntax
$result = $client->abortMultipartUpload([
'Bucket' => '<string>', // REQUIRED
'ExpectedBucketOwner' => '<string>',
'Key' => '<string>', // REQUIRED
'RequestPayer' => 'requester',
'UploadId' => '<string>', // REQUIRED
]);
Parameter Details
Members
- Bucket
-
- Required: Yes
- Type: string
The bucket name to which the upload was taking place.
When using this action with an access point, you must direct requests to the access point hostname. The access point hostname takes the form AccessPointName–AccountId.s3-accesspoint.Region.amazonaws.com. When using this action with an access point through the Amazon Web Services SDKs, you provide the access point ARN in place of the bucket name. For more information about access point ARNs, see Using access points in the Amazon S3 User Guide.
When using this action with Amazon S3 on Outposts, you must direct requests to the S3 on Outposts hostname. The S3 on Outposts hostname takes the form AccessPointName–AccountId.outpostID.s3-outposts.Region.amazonaws.com. When using this action using S3 on Outposts through the Amazon Web Services SDKs, you provide the Outposts bucket ARN in place of the bucket name. For more information about S3 on Outposts ARNs, see Using S3 on Outposts in the Amazon S3 User Guide.
- ExpectedBucketOwner
-
- Type: string
The account ID of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP
403 (Access Denied)error. - Key
-
- Required: Yes
- Type: string
Key of the object for which the multipart upload was initiated.
- RequestPayer
-
- Type: string
Confirms that the requester knows that they will be charged for the request. Bucket owners need not specify this parameter in their requests. For information about downloading objects from requester pays buckets, see Downloading Objects in Requestor Pays Buckets in the Amazon S3 User Guide.
- UploadId
-
- Required: Yes
- Type: string
Upload ID that identifies the multipart upload.
Result Syntax
[
'RequestCharged' => 'requester',
]
Result Details
Members
- RequestCharged
-
- Type: string
If present, indicates that the requester was successfully charged for the request.
Errors
- NoSuchUpload: The specified multipart upload does not exist.
Examples
Example 1: To abort a multipart upload
The following example aborts a multipart upload.
$result = $client->abortMultipartUpload([
'Bucket' => 'examplebucket',
'Key' => 'bigobject',
'UploadId' => 'xadcOB_7YPBOJuoFiQ9cz4P3Pe6FIZwO4f7wN93uHsNBEw97pl5eNwzExg0LAT2dUN91cOmrEQHDsP3WA60CEg--',
]);
Result syntax:
[ ]
CompleteMultipartUpload
$result = $client->completeMultipartUpload([/* ... */]); $promise = $client->completeMultipartUploadAsync([/* ... */]);
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. Because a request could fail after the initial 200 OK response has been sent, it is important that you check the response body to determine whether the request succeeded.
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:
Additional info on response behavior: if there is an internal error in S3 after the request was successfully recieved, a 200 response will be returned with an S3Exception embedded in it; this will still be caught and retried by RetryMiddleware.
Parameter Syntax
$result = $client->completeMultipartUpload([
'Bucket' => '<string>', // REQUIRED
'ExpectedBucketOwner' => '<string>',
'Key' => '<string>', // REQUIRED
'MultipartUpload' => [
'Parts' => [
[
'ETag' => '<string>',
'PartNumber' => <integer>,
],
// ...
],
],
'RequestPayer' => 'requester',
'UploadId' => '<string>', // REQUIRED
]);
Parameter Details
Members
- Bucket
-
- Required: Yes
- Type: string
Name of the bucket to which the multipart upload was initiated.
When using this action with an access point, you must direct requests to the access point hostname. The access point hostname takes the form AccessPointName–AccountId.s3-accesspoint.Region.amazonaws.com. When using this action with an access point through the Amazon Web Services SDKs, you provide the access point ARN in place of the bucket name. For more information about access point ARNs, see Using access points in the Amazon S3 User Guide.
When using this action with Amazon S3 on Outposts, you must direct requests to the S3 on Outposts hostname. The S3 on Outposts hostname takes the form AccessPointName–AccountId.outpostID.s3-outposts.Region.amazonaws.com. When using this action using S3 on Outposts through the Amazon Web Services SDKs, you provide the Outposts bucket ARN in place of the bucket name. For more information about S3 on Outposts ARNs, see Using S3 on Outposts in the Amazon S3 User Guide.
- ExpectedBucketOwner
-
- Type: string
The account ID of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP
403 (Access Denied)error. - Key
-
- Required: Yes
- Type: string
Object key for which the multipart upload was initiated.
- MultipartUpload
-
- Type: CompletedMultipartUpload structure
The container for the multipart upload request information.
- RequestPayer
-
- Type: string
Confirms that the requester knows that they will be charged for the request. Bucket owners need not specify this parameter in their requests. For information about downloading objects from requester pays buckets, see Downloading Objects in Requestor Pays Buckets in the Amazon S3 User Guide.
- UploadId
-
- Required: Yes
- Type: string
ID for the initiated multipart upload.
Result Syntax
[
'Bucket' => '<string>',
'BucketKeyEnabled' => true || false,
'ETag' => '<string>',
'Expiration' => '<string>',
'Key' => '<string>',
'Location' => '<string>',
'ObjectURL' => '<string>',
'RequestCharged' => 'requester',
'SSEKMSKeyId' => '<string>',
'ServerSideEncryption' => 'AES256|aws:kms',
'VersionId' => '<string>',
]
Result Details
Members
- Bucket
-
- Type: string
The name of the bucket that contains the newly created object. Does not return the access point ARN or access point alias if used.
When using this action with an access point, you must direct requests to the access point hostname. The access point hostname takes the form AccessPointName–AccountId.s3-accesspoint.Region.amazonaws.com. When using this action with an access point through the Amazon Web Services SDKs, you provide the access point ARN in place of the bucket name. For more information about access point ARNs, see Using access points in the Amazon S3 User Guide.
When using this action with Amazon S3 on Outposts, you must direct requests to the S3 on Outposts hostname. The S3 on Outposts hostname takes the form AccessPointName–AccountId.outpostID.s3-outposts.Region.amazonaws.com. When using this action using S3 on Outposts through the Amazon Web Services SDKs, you provide the Outposts bucket ARN in place of the bucket name. For more information about S3 on Outposts ARNs, see Using S3 on Outposts in the Amazon S3 User Guide.
- BucketKeyEnabled
-
- Type: boolean
Indicates whether the multipart upload uses an S3 Bucket Key for server-side encryption with Amazon Web Services KMS (SSE-KMS).
- ETag
-
- Type: string
Entity tag that identifies the newly created object’s data. Objects with different object data will have different entity tags. The entity tag is an opaque string. The entity tag may or may not be an MD5 digest of the object data. If the entity tag is not an MD5 digest of the object data, it will contain one or more nonhexadecimal characters and/or will consist of less than 32 or more than 32 hexadecimal digits.
- Expiration
-
- Type: string
If the object expiration is configured, this will contain the expiration date (expiry-date) and rule ID (rule-id). The value of rule-id is URL encoded.
- Key
-
- Type: string
The object key of the newly created object.
- Location
-
- Type: string
The URI that identifies the newly created object.
- ObjectURL
-
- Type: string
The URI of the created object. - RequestCharged
-
- Type: string
If present, indicates that the requester was successfully charged for the request.
- SSEKMSKeyId
-
- Type: string
If present, specifies the ID of the Amazon Web Services Key Management Service (Amazon Web Services KMS) symmetric customer managed key that was used for the object.
- ServerSideEncryption
-
- Type: string
If you specified server-side encryption either with an Amazon S3-managed encryption key or an Amazon Web Services KMS key in your initiate multipart upload request, the response includes this header. It confirms the encryption algorithm that Amazon S3 used to encrypt the object.
- VersionId
-
- Type: string
Version ID of the newly created object, in case the bucket has versioning turned on.
Errors
There are no errors described for this operation.
Examples
Example 1: To complete multipart upload
The following example completes a multipart upload.
$result = $client->completeMultipartUpload([
'Bucket' => 'examplebucket',
'Key' => 'bigobject',
'MultipartUpload' => [
'Parts' => [
[
'ETag' => '"d8c2eafd90c266e19ab9dcacc479f8af"',
'PartNumber' => 1,
],
[
'ETag' => '"d8c2eafd90c266e19ab9dcacc479f8af"',
'PartNumber' => 2,
],
],
],
'UploadId' => '7YPBOJuoFiQ9cz4P3Pe6FIZwO4f7wN93uHsNBEw97pl5eNwzExg0LAT2dUN91cOmrEQHDsP3WA60CEg--',
]);
Result syntax:
[
'Bucket' => 'acexamplebucket',
'ETag' => '"4d9031c7644d8081c2829f4ea23c55f7-2"',
'Key' => 'bigobject',
'Location' => 'https://examplebucket.s3..amazonaws.com/bigobject',
]
CopyObject
$result = $client->copyObject([/* ... */]); $promise = $client->copyObjectAsync([/* ... */]);
Creates a copy of an object that is already stored in Amazon S3.
You can store individual objects of up to 5 TB in Amazon S3. You create a copy of your object up to 5 GB in size in a single atomic action using this API. However, to copy an object greater than 5 GB, you must use the multipart upload Upload Part – Copy API. For more information, see Copy Object Using the REST Multipart Upload API.
All copy requests must be authenticated. Additionally, you must have read access to the source object and write access to the destination bucket. For more information, see REST Authentication. Both the Region that you want to copy the object from and the Region that you want to copy the object to must be enabled for your account.
A copy request might return an error when Amazon S3 receives the copy request or while Amazon S3 is copying the files. If the error occurs before the copy action starts, you receive a standard Amazon S3 error. If the error occurs during the copy operation, the error response is embedded in the 200 OK response. This means that a 200 OK response can contain either a success or an error. Design your application to parse the contents of the response and handle it appropriately.
If the copy is successful, you receive a response with information about the copied object.
If the request is an HTTP 1.1 request, the response is chunk encoded. If it were not, it would not contain the content-length, and you would need to read the entire body.
The copy request charge is based on the storage class and Region that you specify for the destination object. For pricing information, see Amazon S3 pricing.
Amazon S3 transfer acceleration does not support cross-Region copies. If you request a cross-Region copy using a transfer acceleration endpoint, you get a 400 Bad Request error. For more information, see Transfer Acceleration.
Metadata
When copying an object, you can preserve all metadata (default) or specify new metadata. However, the ACL is not preserved and is set to private for the user making the request. To override the default ACL setting, specify a new ACL when generating a copy request. For more information, see Using ACLs.
To specify whether you want the object metadata copied from the source object or replaced with metadata provided in the request, you can optionally add the x-amz-metadata-directive header. When you grant permissions, you can use the s3:x-amz-metadata-directive condition key to enforce certain metadata behavior when objects are uploaded. For more information, see Specifying Conditions in a Policy in the Amazon S3 User Guide. For a complete list of Amazon S3-specific condition keys, see Actions, Resources, and Condition Keys for Amazon S3.
x-amz-copy-source-if Headers
To only copy an object under certain conditions, such as whether the Etag matches or whether the object was modified before or after a specified date, use the following request parameters:
x-amz-copy-source-if-matchx-amz-copy-source-if-none-matchx-amz-copy-source-if-unmodified-sincex-amz-copy-source-if-modified-since
If both the x-amz-copy-source-if-match and x-amz-copy-source-if-unmodified-since headers are present in the request and evaluate as follows, Amazon S3 returns 200 OK and copies the data:
x-amz-copy-source-if-matchcondition evaluates to truex-amz-copy-source-if-unmodified-sincecondition evaluates to false
If both the x-amz-copy-source-if-none-match and x-amz-copy-source-if-modified-since headers are present in the request and evaluate as follows, Amazon S3 returns the 412 Precondition Failed response code:
x-amz-copy-source-if-none-matchcondition evaluates to falsex-amz-copy-source-if-modified-sincecondition evaluates to true
All headers with the x-amz- prefix, including x-amz-copy-source, must be signed.
Server-side encryption
When you perform a CopyObject operation, you can optionally use the appropriate encryption-related headers to encrypt the object using server-side encryption with Amazon Web Services managed encryption keys (SSE-S3 or SSE-KMS) or a customer-provided encryption key. With server-side encryption, Amazon S3 encrypts your data as it writes it to disks in its data centers and decrypts the data when you access it. For more information about server-side encryption, see Using Server-Side Encryption.
If a target object uses SSE-KMS, you can enable an S3 Bucket Key for the object. For more information, see Amazon S3 Bucket Keys in the Amazon S3 User Guide.
Access Control List (ACL)-Specific Request Headers
When copying an object, you can optionally use headers to grant ACL-based permissions. By default, all objects are private. Only the owner has full access control. When adding a new object, you can grant permissions to individual Amazon Web Services accounts or to predefined groups defined by Amazon S3. These permissions are then added to the ACL on the object. For more information, see Access Control List (ACL) Overview and Managing ACLs Using the REST API.
If the bucket that you’re copying objects to uses the bucket owner enforced setting for S3 Object Ownership, ACLs are disabled and no longer affect permissions. Buckets that use this setting only accept PUT requests that don’t specify an ACL or PUT requests that specify bucket owner full control ACLs, such as the bucket-owner-full-control canned ACL or an equivalent form of this ACL expressed in the XML format.
For more information, see Controlling ownership of objects and disabling ACLs in the Amazon S3 User Guide.
If your bucket uses the bucket owner enforced setting for Object Ownership, all objects written to the bucket by any account will be owned by the bucket owner.
Storage Class Options
You can use the CopyObject action to change the storage class of an object that is already stored in Amazon S3 using the StorageClass parameter. For more information, see Storage Classes in the Amazon S3 User Guide.
Versioning
By default, x-amz-copy-source identifies the current version of an object to copy. If the current version is a delete marker, Amazon S3 behaves as if the object was deleted. To copy a different version, use the versionId subresource.
If you enable versioning on the target bucket, Amazon S3 generates a unique version ID for the object being copied. This version ID is different from the version ID of the source object. Amazon S3 returns the version ID of the copied object in the x-amz-version-id response header in the response.
If you do not enable versioning or suspend it on the target bucket, the version ID that Amazon S3 generates is always null.
If the source object’s storage class is GLACIER, you must restore a copy of this object before you can use it as a source object for the copy operation. For more information, see RestoreObject.
The following operations are related to CopyObject:
For more information, see Copying Objects.
Additional info on response behavior: if there is an internal error in S3 after the request was successfully recieved, a 200 response will be returned with an S3Exception embedded in it; this will still be caught and retried by RetryMiddleware.
Parameter Syntax
$result = $client->copyObject([
'ACL' => 'private|public-read|public-read-write|authenticated-read|aws-exec-read|bucket-owner-read|bucket-owner-full-control',
'Bucket' => '<string>', // REQUIRED
'BucketKeyEnabled' => true || false,
'CacheControl' => '<string>',
'ContentDisposition' => '<string>',
'ContentEncoding' => '<string>',
'ContentLanguage' => '<string>',
'ContentType' => '<string>',
'CopySource' => '<string>', // REQUIRED
'CopySourceIfMatch' => '<string>',
'CopySourceIfModifiedSince' => <integer || string || DateTime>,
'CopySourceIfNoneMatch' => '<string>',
'CopySourceIfUnmodifiedSince' => <integer || string || DateTime>,
'CopySourceSSECustomerAlgorithm' => '<string>',
'CopySourceSSECustomerKey' => '<string>',
'CopySourceSSECustomerKeyMD5' => '<string>',
'ExpectedBucketOwner' => '<string>',
'ExpectedSourceBucketOwner' => '<string>',
'Expires' => <integer || string || DateTime>,
'GrantFullControl' => '<string>',
'GrantRead' => '<string>',
'GrantReadACP' => '<string>',
'GrantWriteACP' => '<string>',
'Key' => '<string>', // REQUIRED
'Metadata' => ['<string>', ...],
'MetadataDirective' => 'COPY|REPLACE',
'ObjectLockLegalHoldStatus' => 'ON|OFF',
'ObjectLockMode' => 'GOVERNANCE|COMPLIANCE',
'ObjectLockRetainUntilDate' => <integer || string || DateTime>,
'RequestPayer' => 'requester',
'SSECustomerAlgorithm' => '<string>',
'SSECustomerKey' => '<string>',
'SSECustomerKeyMD5' => '<string>',
'SSEKMSEncryptionContext' => '<string>',
'SSEKMSKeyId' => '<string>',
'ServerSideEncryption' => 'AES256|aws:kms',
'StorageClass' => 'STANDARD|REDUCED_REDUNDANCY|STANDARD_IA|ONEZONE_IA|INTELLIGENT_TIERING|GLACIER|DEEP_ARCHIVE|OUTPOSTS|GLACIER_IR',
'Tagging' => '<string>',
'TaggingDirective' => 'COPY|REPLACE',
'WebsiteRedirectLocation' => '<string>',
]);
Parameter Details
Members
- ACL
-
- Type: string
The canned ACL to apply to the object.
This action is not supported by Amazon S3 on Outposts.
- Bucket
-
- Required: Yes
- Type: string
The name of the destination bucket.
When using this action with an access point, you must direct requests to the access point hostname. The access point hostname takes the form AccessPointName–AccountId.s3-accesspoint.Region.amazonaws.com. When using this action with an access point through the Amazon Web Services SDKs, you provide the access point ARN in place of the bucket name. For more information about access point ARNs, see Using access points in the Amazon S3 User Guide.
When using this action with Amazon S3 on Outposts, you must direct requests to the S3 on Outposts hostname. The S3 on Outposts hostname takes the form AccessPointName–AccountId.outpostID.s3-outposts.Region.amazonaws.com. When using this action using S3 on Outposts through the Amazon Web Services SDKs, you provide the Outposts bucket ARN in place of the bucket name. For more information about S3 on Outposts ARNs, see Using S3 on Outposts in the Amazon S3 User Guide.
- BucketKeyEnabled
-
- Type: boolean
Specifies whether Amazon S3 should use an S3 Bucket Key for object encryption with server-side encryption using AWS KMS (SSE-KMS). Setting this header to
truecauses Amazon S3 to use an S3 Bucket Key for object encryption with SSE-KMS.Specifying this header with a COPY action doesn’t affect bucket-level settings for S3 Bucket Key.
- CacheControl
-
- Type: string
Specifies caching behavior along the request/reply chain.
- ContentDisposition
-
- Type: string
Specifies presentational information for the object.
- ContentEncoding
-
- Type: string
Specifies what content encodings have been applied to the object and thus what decoding mechanisms must be applied to obtain the media-type referenced by the Content-Type header field.
- ContentLanguage
-
- Type: string
The language the content is in.
- ContentType
-
- Type: string
A standard MIME type describing the format of the object data.
- CopySource
-
- Required: Yes
- Type: string
Specifies the source object for the copy operation. You specify the value in one of two formats, depending on whether you want to access the source object through an access point:
- For objects not accessed through an access point, specify the name of the source bucket and the key of the source object, separated by a slash (/). For example, to copy the object
reports/january.pdffrom the bucketawsexamplebucket, useawsexamplebucket/reports/january.pdf. The value must be URL encoded. - For objects accessed through access points, specify the Amazon Resource Name (ARN) of the object as accessed through the access point, in the format
arn:aws:s3:<Region>:<account-id>:accesspoint/<access-point-name>/object/<key>. For example, to copy the objectreports/january.pdfthrough access pointmy-access-pointowned by account123456789012in Regionus-west-2, use the URL encoding ofarn:aws:s3:us-west-2:123456789012:accesspoint/my-access-point/object/reports/january.pdf. The value must be URL encoded.Amazon S3 supports copy operations using access points only when the source and destination buckets are in the same Amazon Web Services Region.Alternatively, for objects accessed through Amazon S3 on Outposts, specify the ARN of the object as accessed in the formatarn:aws:s3-outposts:<Region>:<account-id>:outpost/<outpost-id>/object/<key>. For example, to copy the objectreports/january.pdfthrough outpostmy-outpostowned by account123456789012in Regionus-west-2, use the URL encoding ofarn:aws:s3-outposts:us-west-2:123456789012:outpost/my-outpost/object/reports/january.pdf. The value must be URL encoded.
To copy a specific version of an object, append
?versionId=<version-id>to the value (for example,awsexamplebucket/reports/january.pdf?versionId=QUpfdndhfd8438MNFDN93jdnJFkdmqnh893). If you don’t specify a version ID, Amazon S3 copies the latest version of the source object. - CopySourceIfMatch
-
- Type: string
Copies the object if its entity tag (ETag) matches the specified tag.
- CopySourceIfModifiedSince
-
- Type: timestamp (string|DateTime or anything parsable by strtotime)
Copies the object if it has been modified since the specified time.
- CopySourceIfNoneMatch
-
- Type: string
Copies the object if its entity tag (ETag) is different than the specified ETag.
- CopySourceIfUnmodifiedSince
-
- Type: timestamp (string|DateTime or anything parsable by strtotime)
Copies the object if it hasn’t been modified since the specified time.
- CopySourceSSECustomerAlgorithm
-
- Type: string
Specifies the algorithm to use when decrypting the source object (for example, AES256).
- CopySourceSSECustomerKey
-
- Type: string
Specifies the customer-provided encryption key for Amazon S3 to use to decrypt the source object. The encryption key provided in this header must be one that was used when the source object was created.
This value will be base64 encoded on your behalf. - CopySourceSSECustomerKeyMD5
-
- Type: string
Specifies the 128-bit MD5 digest of the encryption key according to RFC 1321. Amazon S3 uses this header for a message integrity check to ensure that the encryption key was transmitted without error.
- ExpectedBucketOwner
-
- Type: string
The account ID of the expected destination bucket owner. If the destination bucket is owned by a different account, the request will fail with an HTTP
403 (Access Denied)error. - ExpectedSourceBucketOwner
-
- Type: string
The account ID of the expected source bucket owner. If the source bucket is owned by a different account, the request will fail with an HTTP
403 (Access Denied)error. - Expires
-
- Type: timestamp (string|DateTime or anything parsable by strtotime)
The date and time at which the object is no longer cacheable.
- GrantFullControl
-
- Type: string
Gives the grantee READ, READ_ACP, and WRITE_ACP permissions on the object.
This action is not supported by Amazon S3 on Outposts.
- GrantRead
-
- Type: string
Allows grantee to read the object data and its metadata.
This action is not supported by Amazon S3 on Outposts.
- GrantReadACP
-
- Type: string
Allows grantee to read the object ACL.
This action is not supported by Amazon S3 on Outposts.
- GrantWriteACP
-
- Type: string
Allows grantee to write the ACL for the applicable object.
This action is not supported by Amazon S3 on Outposts.
- Key
-
- Required: Yes
- Type: string
The key of the destination object.
- Metadata
-
- Type: Associative array of custom strings keys (MetadataKey) to strings
A map of metadata to store with the object in S3.
- MetadataDirective
-
- Type: string
Specifies whether the metadata is copied from the source object or replaced with metadata provided in the request.
- ObjectLockLegalHoldStatus
-
- Type: string
Specifies whether you want to apply a Legal Hold to the copied object.
- ObjectLockMode
-
- Type: string
The Object Lock mode that you want to apply to the copied object.
- ObjectLockRetainUntilDate
-
- Type: timestamp (string|DateTime or anything parsable by strtotime)
The date and time when you want the copied object’s Object Lock to expire.
- RequestPayer
-
- Type: string
Confirms that the requester knows that they will be charged for the request. Bucket owners need not specify this parameter in their requests. For information about downloading objects from requester pays buckets, see Downloading Objects in Requestor Pays Buckets in the Amazon S3 User Guide.
- SSECustomerAlgorithm
-
- Type: string
Specifies the algorithm to use to when encrypting the object (for example, AES256).
- SSECustomerKey
-
- Type: string
Specifies the customer-provided encryption key for Amazon S3 to use in encrypting data. This value is used to store the object and then it is discarded; Amazon S3 does not store the encryption key. The key must be appropriate for use with the algorithm specified in the
x-amz-server-side-encryption-customer-algorithmheader.This value will be base64 encoded on your behalf. - SSECustomerKeyMD5
-
- Type: string
Specifies the 128-bit MD5 digest of the encryption key according to RFC 1321. Amazon S3 uses this header for a message integrity check to ensure that the encryption key was transmitted without error.
- SSEKMSEncryptionContext
-
- Type: string
Specifies the Amazon Web Services KMS Encryption Context to use for object encryption. The value of this header is a base64-encoded UTF-8 string holding JSON with the encryption context key-value pairs.
- SSEKMSKeyId
-
- Type: string
Specifies the Amazon Web Services KMS key ID to use for object encryption. All GET and PUT requests for an object protected by Amazon Web Services KMS will fail if not made via SSL or using SigV4. For information about configuring using any of the officially supported Amazon Web Services SDKs and Amazon Web Services CLI, see Specifying the Signature Version in Request Authentication in the Amazon S3 User Guide.
- ServerSideEncryption
-
- Type: string
The server-side encryption algorithm used when storing this object in Amazon S3 (for example, AES256, aws:kms).
- StorageClass
-
- Type: string
By default, Amazon S3 uses the STANDARD Storage Class to store newly created objects. The STANDARD storage class provides high durability and high availability. Depending on performance needs, you can specify a different Storage Class. Amazon S3 on Outposts only uses the OUTPOSTS Storage Class. For more information, see Storage Classes in the Amazon S3 User Guide.
- Tagging
-
- Type: string
The tag-set for the object destination object this value must be used in conjunction with the
TaggingDirective. The tag-set must be encoded as URL Query parameters. - TaggingDirective
-
- Type: string
Specifies whether the object tag-set are copied from the source object or replaced with tag-set provided in the request.
- WebsiteRedirectLocation
-
- Type: string
If the bucket is configured as a website, redirects requests for this object to another object in the same bucket or to an external URL. Amazon S3 stores the value of this header in the object metadata.
Result Syntax
[
'BucketKeyEnabled' => true || false,
'CopyObjectResult' => [
'ETag' => '<string>',
'LastModified' => <DateTime>,
],
'CopySourceVersionId' => '<string>',
'Expiration' => '<string>',
'ObjectURL' => '<string>',
'RequestCharged' => 'requester',
'SSECustomerAlgorithm' => '<string>',
'SSECustomerKeyMD5' => '<string>',
'SSEKMSEncryptionContext' => '<string>',
'SSEKMSKeyId' => '<string>',
'ServerSideEncryption' => 'AES256|aws:kms',
'VersionId' => '<string>',
]
Result Details
Members
- BucketKeyEnabled
-
- Type: boolean
Indicates whether the copied object uses an S3 Bucket Key for server-side encryption with Amazon Web Services KMS (SSE-KMS).
- CopyObjectResult
-
- Type: CopyObjectResult structure
Container for all response elements.
- CopySourceVersionId
-
- Type: string
Version of the copied object in the destination bucket.
- Expiration
-
- Type: string
If the object expiration is configured, the response includes this header.
- ObjectURL
-
- Type: string
The URI of the created object. - RequestCharged
-
- Type: string
If present, indicates that the requester was successfully charged for the request.
- SSECustomerAlgorithm
-
- Type: string
If server-side encryption with a customer-provided encryption key was requested, the response will include this header confirming the encryption algorithm used.
- SSECustomerKeyMD5
-
- Type: string
If server-side encryption with a customer-provided encryption key was requested, the response will include this header to provide round-trip message integrity verification of the customer-provided encryption key.
- SSEKMSEncryptionContext
-
- Type: string
If present, specifies the Amazon Web Services KMS Encryption Context to use for object encryption. The value of this header is a base64-encoded UTF-8 string holding JSON with the encryption context key-value pairs.
- SSEKMSKeyId
-
- Type: string
If present, specifies the ID of the Amazon Web Services Key Management Service (Amazon Web Services KMS) symmetric customer managed key that was used for the object.
- ServerSideEncryption
-
- Type: string
The server-side encryption algorithm used when storing this object in Amazon S3 (for example, AES256, aws:kms).
- VersionId
-
- Type: string
Version ID of the newly created copy.
Errors
- ObjectNotInActiveTierError: The source object of the COPY action is not in the active tier and is only stored in Amazon S3 Glacier.
Examples
Example 1: To copy an object
The following example copies an object from one bucket to another.
$result = $client->copyObject([
'Bucket' => 'destinationbucket',
'CopySource' => '/sourcebucket/HappyFacejpg',
'Key' => 'HappyFaceCopyjpg',
]);
Result syntax:
[
'CopyObjectResult' => [
'ETag' => '"6805f2cfc46c0f04559748bb039d69ae"',
'LastModified' => ,
],
]
CreateBucket
$result = $client->createBucket([/* ... */]); $promise = $client->createBucketAsync([/* ... */]);
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 includes the BucketOwnerEnforced value for the x-amz-object-ownership header, your request can either not specify an ACL or specify bucket owner full control ACLs, such as the bucket-owner-full-control canned ACL or an equivalent ACL expressed in the XML format. 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-aclrequest 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, andx-amz-grant-full-controlheaders. 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 accounturi– if you are granting permissions to a predefined groupemailAddress– if the value specified is the email address of an Amazon Web Services accountUsing 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-readheader 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
CreateBucketrequest 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, boths3:CreateBucketands3:PutBucketAclpermissions are needed. If the ACL theCreateBucketrequest is private or doesn’t specify any ACLs, onlys3:CreateBucketpermission is needed. - Object Lock – If
ObjectLockEnabledForBucketis set to true in yourCreateBucketrequest,s3:PutBucketObjectLockConfigurationands3:PutBucketVersioningpermissions are required. - S3 Object Ownership – If your CreateBucket request includes the the
x-amz-object-ownershipheader,s3:PutBucketOwnershipControlspermission is required.
The following operations are related to CreateBucket:
Parameter Syntax
$result = $client->createBucket([
'ACL' => 'private|public-read|public-read-write|authenticated-read',
'Bucket' => '<string>', // REQUIRED
'CreateBucketConfiguration' => [
'LocationConstraint' => 'ap-northeast-1|ap-southeast-2|ap-southeast-1|cn-north-1|eu-central-1|eu-west-1|us-east-1|us-west-1|us-west-2|sa-east-1',
],
'GrantFullControl' => '<string>',
'GrantRead' => '<string>',
'GrantReadACP' => '<string>',
'GrantWrite' => '<string>',
'GrantWriteACP' => '<string>',
'ObjectLockEnabledForBucket' => true || false,
'ObjectOwnership' => 'BucketOwnerPreferred|ObjectWriter|BucketOwnerEnforced',
]);
Parameter Details
Members
- ACL
-
- Type: string
The canned ACL to apply to the bucket.
- Bucket
-
- Required: Yes
- Type: string
The name of the bucket to create.
- CreateBucketConfiguration
-
- Type: CreateBucketConfiguration structure
The configuration information for the bucket.
- GrantFullControl
-
- Type: string
Allows grantee the read, write, read ACP, and write ACP permissions on the bucket.
- GrantRead
-
- Type: string
Allows grantee to list the objects in the bucket.
- GrantReadACP
-
- Type: string
Allows grantee to read the bucket ACL.
- GrantWrite
-
- Type: string
Allows grantee to create new objects in the bucket.
For the bucket and object owners of existing objects, also allows deletions and overwrites of those objects.
- GrantWriteACP
-
- Type: string
Allows grantee to write the ACL for the applicable bucket.
- ObjectLockEnabledForBucket
-
- Type: boolean
Specifies whether you want S3 Object Lock to be enabled for the new bucket.
- ObjectOwnership
-
- Type: string
The container element for object ownership for a bucket’s ownership controls.
BucketOwnerPreferred – Objects uploaded to the bucket change ownership to the bucket owner if the objects are uploaded with the
bucket-owner-full-controlcanned ACL.ObjectWriter – The uploading account will own the object if the object is uploaded with the
bucket-owner-full-controlcanned ACL.BucketOwnerEnforced – Access control lists (ACLs) are disabled and no longer affect permissions. The bucket owner automatically owns and has full control over every object in the bucket. The bucket only accepts PUT requests that don’t specify an ACL or bucket owner full control ACLs, such as the
bucket-owner-full-controlcanned ACL or an equivalent form of this ACL expressed in the XML format.
Result Syntax
[
'Location' => '<string>',
]
Result Details
Members
- Location
-
- Type: string
Specifies the Region where the bucket will be created. If you are creating a bucket on the US East (N. Virginia) Region (us-east-1), you do not need to specify the location.
Errors
- BucketAlreadyExists: The requested bucket name is not available. The bucket namespace is shared by all users of the system. Select a different name and try again.
- BucketAlreadyOwnedByYou: The bucket you tried to create already exists, and you own it. Amazon S3 returns this error in all Amazon Web Services Regions except in the North Virginia Region. For legacy compatibility, if you re-create an existing bucket that you already own in the North Virginia Region, Amazon S3 returns 200 OK and resets the bucket access control lists (ACLs).
Examples
Example 1: To create a bucket in a specific region
The following example creates a bucket. The request specifies an AWS region where to create the bucket.
$result = $client->createBucket([
'Bucket' => 'examplebucket',
'CreateBucketConfiguration' => [
'LocationConstraint' => 'eu-west-1',
],
]);
Result syntax:
[
'Location' => 'http://examplebucket..s3.amazonaws.com/',
]
Example 2: To create a bucket
The following example creates a bucket.
$result = $client->createBucket([
'Bucket' => 'examplebucket',
]);
Result syntax:
[
'Location' => '/examplebucket',
]
CreateMultipartUpload
$result = $client->createMultipartUpload([/* ... */]); $promise = $client->createMultipartUploadAsync([/* ... */]);
This action initiates a multipart upload and returns an upload ID. This upload ID is used to associate all of the parts in the specific multipart upload. You specify this upload ID in each of your subsequent upload part requests (see UploadPart). You also include this upload ID in the final request to either complete or abort the multipart upload request.
For more information about multipart uploads, see Multipart Upload Overview.
If you have configured a lifecycle rule to abort incomplete multipart uploads, the upload must complete within the number of days specified in the bucket lifecycle configuration. Otherwise, the incomplete multipart upload becomes eligible for an abort action and Amazon S3 aborts the multipart upload. For more information, see Aborting Incomplete Multipart Uploads Using a Bucket Lifecycle Policy.
For information about the permissions required to use the multipart upload API, see Multipart Upload and Permissions.
For request signing, multipart upload is just a series of regular requests. You initiate a multipart upload, send one or more requests to upload parts, and then complete the multipart upload process. You sign each request individually. There is nothing special about signing multipart upload requests. For more information about signing, see Authenticating Requests (Amazon Web Services Signature Version 4).
After you initiate a multipart upload and upload one or more parts, to stop being charged for storing the uploaded parts, you must either complete or abort the multipart upload. Amazon S3 frees up the space used to store the parts and stop charging you for storing them only after you either complete or abort a multipart upload.
You can optionally request server-side encryption. For server-side encryption, Amazon S3 encrypts your data as it writes it to disks in its data centers and decrypts it when you access it. You can provide your own encryption key, or use Amazon Web Services KMS keys or Amazon S3-managed encryption keys. If you choose to provide your own encryption key, the request headers you provide in UploadPart and UploadPartCopy requests must match the headers you used in the request to initiate the upload by using CreateMultipartUpload.
To perform a multipart upload with encryption using an Amazon Web Services KMS key, the requester must have permission to the kms:Decrypt and kms:GenerateDataKey* actions on the key. These permissions are required because Amazon S3 must decrypt and read data from the encrypted file parts before it completes the multipart upload. For more information, see Multipart upload API and permissions in the Amazon S3 User Guide.
If your Identity and Access Management (IAM) user or role is in the same Amazon Web Services account as the KMS key, then you must have these permissions on the key policy. If your IAM user or role belongs to a different account than the key, then you must have the permissions on both the key policy and your IAM user or role.
For more information, see Protecting Data Using Server-Side Encryption.
- Access Permissions
- When copying an object, you can optionally specify the accounts or groups that should be granted specific permissions on the new object. There are two ways to grant the permissions using the request headers:
- Specify a canned ACL with the
x-amz-aclrequest header. For more information, see Canned ACL. - Specify access permissions explicitly with the
x-amz-grant-read,x-amz-grant-read-acp,x-amz-grant-write-acp, andx-amz-grant-full-controlheaders. These parameters map to the set of permissions that Amazon S3 supports in an ACL. For more information, see Access Control List (ACL) Overview.
You can use either a canned ACL or specify access permissions explicitly. You cannot do both.
- Specify a canned ACL with the
- Server-Side- Encryption-Specific Request Headers
- You can optionally tell Amazon S3 to encrypt data at rest using server-side encryption. Server-side encryption is for data encryption at rest. Amazon S3 encrypts your data as it writes it to disks in its data centers and decrypts it when you access it. The option you use depends on whether you want to use Amazon Web Services managed encryption keys or provide your own encryption key.
- Use encryption keys managed by Amazon S3 or customer managed key stored in Amazon Web Services Key Management Service (Amazon Web Services KMS) – If you want Amazon Web Services to manage the keys used to encrypt data, specify the following headers in the request.
- x-amz-server-side-encryption
- x-amz-server-side-encryption-aws-kms-key-id
- x-amz-server-side-encryption-context
If you specify
x-amz-server-side-encryption:aws:kms, but don’t providex-amz-server-side-encryption-aws-kms-key-id, Amazon S3 uses the Amazon Web Services managed key in Amazon Web Services KMS to protect the data.All GET and PUT requests for an object protected by Amazon Web Services KMS fail if you don’t make them with SSL or by using SigV4.
For more information about server-side encryption with KMS key (SSE-KMS), see Protecting Data Using Server-Side Encryption with KMS keys.
- Use customer-provided encryption keys – If you want to manage your own encryption keys, provide all the following headers in the request.
- 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 server-side encryption with KMS keys (SSE-KMS), see Protecting Data Using Server-Side Encryption with KMS keys.
- Use encryption keys managed by Amazon S3 or customer managed key stored in Amazon Web Services Key Management Service (Amazon Web Services KMS) – If you want Amazon Web Services to manage the keys used to encrypt data, specify the following headers in the request.
- Access-Control-List (ACL)-Specific Request Headers
- You also can use the following access control–related headers with this operation. By default, all objects are private. Only the owner has full access control. When adding a new object, you can grant permissions to individual Amazon Web Services accounts or to predefined groups defined by Amazon S3. These permissions are then added to the access control list (ACL) on the object. For more information, see Using ACLs. With this operation, you can grant access permissions using one of the following two methods:
- Specify a canned ACL (
x-amz-acl) — 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 — To explicitly grant access permissions to specific Amazon Web Services accounts or groups, use the following headers. Each header maps to specific permissions that Amazon S3 supports in an ACL. For more information, see Access Control List (ACL) Overview. In the header, you specify a list of grantees who get the specific permission. To grant permissions explicitly, use:
- x-amz-grant-read
- x-amz-grant-write
- x-amz-grant-read-acp
- x-amz-grant-write-acp
- x-amz-grant-full-control
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 accounturi– if you are granting permissions to a predefined groupemailAddress– if the value specified is the email address of an Amazon Web Services accountUsing 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-readheader 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"
- Specify a canned ACL (
The following operations are related to CreateMultipartUpload:
Parameter Syntax
$result = $client->createMultipartUpload([
'ACL' => 'private|public-read|public-read-write|authenticated-read|aws-exec-read|bucket-owner-read|bucket-owner-full-control',
'Bucket' => '<string>', // REQUIRED
'BucketKeyEnabled' => true || false,
'CacheControl' => '<string>',
'ContentDisposition' => '<string>',
'ContentEncoding' => '<string>',
'ContentLanguage' => '<string>',
'ContentType' => '<string>',
'ExpectedBucketOwner' => '<string>',
'Expires' => <integer || string || DateTime>,
'GrantFullControl' => '<string>',
'GrantRead' => '<string>',
'GrantReadACP' => '<string>',
'GrantWriteACP' => '<string>',
'Key' => '<string>', // REQUIRED
'Metadata' => ['<string>', ...],
'ObjectLockLegalHoldStatus' => 'ON|OFF',
'ObjectLockMode' => 'GOVERNANCE|COMPLIANCE',
'ObjectLockRetainUntilDate' => <integer || string || DateTime>,
'RequestPayer' => 'requester',
'SSECustomerAlgorithm' => '<string>',
'SSECustomerKey' => '<string>',
'SSECustomerKeyMD5' => '<string>',
'SSEKMSEncryptionContext' => '<string>',
'SSEKMSKeyId' => '<string>',
'ServerSideEncryption' => 'AES256|aws:kms',
'StorageClass' => 'STANDARD|REDUCED_REDUNDANCY|STANDARD_IA|ONEZONE_IA|INTELLIGENT_TIERING|GLACIER|DEEP_ARCHIVE|OUTPOSTS|GLACIER_IR',
'Tagging' => '<string>',
'WebsiteRedirectLocation' => '<string>',
]);
Parameter Details
Members
- ACL
-
- Type: string
The canned ACL to apply to the object.
This action is not supported by Amazon S3 on Outposts.
- Bucket
-
- Required: Yes
- Type: string
The name of the bucket to which to initiate the upload
When using this action with an access point, you must direct requests to the access point hostname. The access point hostname takes the form AccessPointName–AccountId.s3-accesspoint.Region.amazonaws.com. When using this action with an access point through the Amazon Web Services SDKs, you provide the access point ARN in place of the bucket name. For more information about access point ARNs, see Using access points in the Amazon S3 User Guide.
When using this action with Amazon S3 on Outposts, you must direct requests to the S3 on Outposts hostname. The S3 on Outposts hostname takes the form AccessPointName–AccountId.outpostID.s3-outposts.Region.amazonaws.com. When using this action using S3 on Outposts through the Amazon Web Services SDKs, you provide the Outposts bucket ARN in place of the bucket name. For more information about S3 on Outposts ARNs, see Using S3 on Outposts in the Amazon S3 User Guide.
- BucketKeyEnabled
-
- Type: boolean
Specifies whether Amazon S3 should use an S3 Bucket Key for object encryption with server-side encryption using AWS KMS (SSE-KMS). Setting this header to
truecauses Amazon S3 to use an S3 Bucket Key for object encryption with SSE-KMS.Specifying this header with an object action doesn’t affect bucket-level settings for S3 Bucket Key.
- CacheControl
-
- Type: string
Specifies caching behavior along the request/reply chain.
- ContentDisposition
-
- Type: string
Specifies presentational information for the object.
- ContentEncoding
-
- Type: string
Specifies what content encodings have been applied to the object and thus what decoding mechanisms must be applied to obtain the media-type referenced by the Content-Type header field.
- ContentLanguage
-
- Type: string
The language the content is in.
- ContentType
-
- Type: string
A standard MIME type describing the format of the object data.
- ExpectedBucketOwner
-
- Type: string
The account ID of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP
403 (Access Denied)error. - Expires
-
- Type: timestamp (string|DateTime or anything parsable by strtotime)
The date and time at which the object is no longer cacheable.
- GrantFullControl
-
- Type: string
Gives the grantee READ, READ_ACP, and WRITE_ACP permissions on the object.
This action is not supported by Amazon S3 on Outposts.
- GrantRead
-
- Type: string
Allows grantee to read the object data and its metadata.
This action is not supported by Amazon S3 on Outposts.
- GrantReadACP
-
- Type: string
Allows grantee to read the object ACL.
This action is not supported by Amazon S3 on Outposts.
- GrantWriteACP
-
- Type: string
Allows grantee to write the ACL for the applicable object.
This action is not supported by Amazon S3 on Outposts.
- Key
-
- Required: Yes
- Type: string
Object key for which the multipart upload is to be initiated.
- Metadata
-
- Type: Associative array of custom strings keys (MetadataKey) to strings
A map of metadata to store with the object in S3.
- ObjectLockLegalHoldStatus
-
- Type: string
Specifies whether you want to apply a Legal Hold to the uploaded object.
- ObjectLockMode
-
- Type: string
Specifies the Object Lock mode that you want to apply to the uploaded object.
- ObjectLockRetainUntilDate
-
- Type: timestamp (string|DateTime or anything parsable by strtotime)
Specifies the date and time when you want the Object Lock to expire.
- RequestPayer
-
- Type: string
Confirms that the requester knows that they will be charged for the request. Bucket owners need not specify this parameter in their requests. For information about downloading objects from requester pays buckets, see Downloading Objects in Requestor Pays Buckets in the Amazon S3 User Guide.
- SSECustomerAlgorithm
-
- Type: string
Specifies the algorithm to use to when encrypting the object (for example, AES256).
- SSECustomerKey
-
- Type: string
Specifies the customer-provided encryption key for Amazon S3 to use in encrypting data. This value is used to store the object and then it is discarded; Amazon S3 does not store the encryption key. The key must be appropriate for use with the algorithm specified in the
x-amz-server-side-encryption-customer-algorithmheader.This value will be base64 encoded on your behalf. - SSECustomerKeyMD5
-
- Type: string
Specifies the 128-bit MD5 digest of the encryption key according to RFC 1321. Amazon S3 uses this header for a message integrity check to ensure that the encryption key was transmitted without error.
- SSEKMSEncryptionContext
-
- Type: string
Specifies the Amazon Web Services KMS Encryption Context to use for object encryption. The value of this header is a base64-encoded UTF-8 string holding JSON with the encryption context key-value pairs.
- SSEKMSKeyId
-
- Type: string
Specifies the ID of the symmetric customer managed key to use for object encryption. All GET and PUT requests for an object protected by Amazon Web Services KMS will fail if not made via SSL or using SigV4. For information about configuring using any of the officially supported Amazon Web Services SDKs and Amazon Web Services CLI, see Specifying the Signature Version in Request Authentication in the Amazon S3 User Guide.
- ServerSideEncryption
-
- Type: string
The server-side encryption algorithm used when storing this object in Amazon S3 (for example, AES256, aws:kms).
- StorageClass
-
- Type: string
By default, Amazon S3 uses the STANDARD Storage Class to store newly created objects. The STANDARD storage class provides high durability and high availability. Depending on performance needs, you can specify a different Storage Class. Amazon S3 on Outposts only uses the OUTPOSTS Storage Class. For more information, see Storage Classes in the Amazon S3 User Guide.
- Tagging
-
- Type: string
The tag-set for the object. The tag-set must be encoded as URL Query parameters.
- WebsiteRedirectLocation
-
- Type: string
If the bucket is configured as a website, redirects requests for this object to another object in the same bucket or to an external URL. Amazon S3 stores the value of this header in the object metadata.
Result Syntax
[
'AbortDate' => <DateTime>,
'AbortRuleId' => '<string>',
'Bucket' => '<string>',
'BucketKeyEnabled' => true || false,
'Key' => '<string>',
'RequestCharged' => 'requester',
'SSECustomerAlgorithm' => '<string>',
'SSECustomerKeyMD5' => '<string>',
'SSEKMSEncryptionContext' => '<string>',
'SSEKMSKeyId' => '<string>',
'ServerSideEncryption' => 'AES256|aws:kms',
'UploadId' => '<string>',
]
Result Details
Members
- AbortDate
-
- Type: timestamp (string|DateTime or anything parsable by strtotime)
If the bucket has a lifecycle rule configured with an action to abort incomplete multipart uploads and the prefix in the lifecycle rule matches the object name in the request, the response includes this header. The header indicates when the initiated multipart upload becomes eligible for an abort operation. For more information, see Aborting Incomplete Multipart Uploads Using a Bucket Lifecycle Policy.
The response also includes the
x-amz-abort-rule-idheader that provides the ID of the lifecycle configuration rule that defines this action. - AbortRuleId
-
- Type: string
This header is returned along with the
x-amz-abort-dateheader. It identifies the applicable lifecycle configuration rule that defines the action to abort incomplete multipart uploads. - Bucket
-
- Type: string
The name of the bucket to which the multipart upload was initiated. Does not return the access point ARN or access point alias if used.
When using this action with an access point, you must direct requests to the access point hostname. The access point hostname takes the form AccessPointName–AccountId.s3-accesspoint.Region.amazonaws.com. When using this action with an access point through the Amazon Web Services SDKs, you provide the access point ARN in place of the bucket name. For more information about access point ARNs, see Using access points in the Amazon S3 User Guide.
When using this action with Amazon S3 on Outposts, you must direct requests to the S3 on Outposts hostname. The S3 on Outposts hostname takes the form AccessPointName–AccountId.outpostID.s3-outposts.Region.amazonaws.com. When using this action using S3 on Outposts through the Amazon Web Services SDKs, you provide the Outposts bucket ARN in place of the bucket name. For more information about S3 on Outposts ARNs, see Using S3 on Outposts in the Amazon S3 User Guide.
- BucketKeyEnabled
-
- Type: boolean
Indicates whether the multipart upload uses an S3 Bucket Key for server-side encryption with Amazon Web Services KMS (SSE-KMS).
- Key
-
- Type: string
Object key for which the multipart upload was initiated.
- RequestCharged
-
- Type: string
If present, indicates that the requester was successfully charged for the request.
- SSECustomerAlgorithm
-
- Type: string
If server-side encryption with a customer-provided encryption key was requested, the response will include this header confirming the encryption algorithm used.
- SSECustomerKeyMD5
-
- Type: string
If server-side encryption with a customer-provided encryption key was requested, the response will include this header to provide round-trip message integrity verification of the customer-provided encryption key.
- SSEKMSEncryptionContext
-
- Type: string
If present, specifies the Amazon Web Services KMS Encryption Context to use for object encryption. The value of this header is a base64-encoded UTF-8 string holding JSON with the encryption context key-value pairs.
- SSEKMSKeyId
-
- Type: string
If present, specifies the ID of the Amazon Web Services Key Management Service (Amazon Web Services KMS) symmetric customer managed key that was used for the object.
- ServerSideEncryption
-
- Type: string
The server-side encryption algorithm used when storing this object in Amazon S3 (for example, AES256, aws:kms).
- UploadId
-
- Type: string
ID for the initiated multipart upload.
Errors
There are no errors described for this operation.
Examples
Example 1: To initiate a multipart upload
The following example initiates a multipart upload.
$result = $client->createMultipartUpload([
'Bucket' => 'examplebucket',
'Key' => 'largeobject',
]);
Result syntax:
[
'Bucket' => 'examplebucket',
'Key' => 'largeobject',
'UploadId' => 'ibZBv_75gd9r8lH_gqXatLdxMVpAlj6ZQjEs.OwyF3953YdwbcQnMA2BLGn8Lx12fQNICtMw5KyteFeHw.Sjng--',
]
DeleteBucket
$result = $client->deleteBucket([/* ... */]); $promise = $client->deleteBucketAsync([/* ... */]);
Deletes the S3 bucket. All objects (including all object versions and delete markers) in the bucket must be deleted before the bucket itself can be deleted.
Related Resources
Parameter Syntax
$result = $client->deleteBucket([
'Bucket' => '<string>', // REQUIRED
'ExpectedBucketOwner' => '<string>',
]);
Parameter Details
Members
- Bucket
-
- Required: Yes
- Type: string
Specifies the bucket being deleted.
- ExpectedBucketOwner
-
- Type: string
The account ID of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP
403 (Access Denied)error.
Result Syntax
[]
Result Details
Errors
There are no errors described for this operation.
Examples
Example 1: To delete a bucket
The following example deletes the specified bucket.
$result = $client->deleteBucket([
'Bucket' => 'forrandall2',
]);
DeleteBucketAnalyticsConfiguration
$result = $client->deleteBucketAnalyticsConfiguration([/* ... */]); $promise = $client->deleteBucketAnalyticsConfigurationAsync([/* ... */]);
Deletes an analytics configuration for the bucket (specified by the analytics configuration ID).
To use this operation, you must have permissions to perform the s3:PutAnalyticsConfiguration action. The bucket owner has this permission by default. The bucket owner 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.
For information about the Amazon S3 analytics feature, see Amazon S3 Analytics – Storage Class Analysis.
The following operations are related to DeleteBucketAnalyticsConfiguration:
Parameter Syntax
$result = $client->deleteBucketAnalyticsConfiguration([
'Bucket' => '<string>', // REQUIRED
'ExpectedBucketOwner' => '<string>',
'Id' => '<string>', // REQUIRED
]);
Parameter Details
Members
- Bucket
-
- Required: Yes
- Type: string
The name of the bucket from which an analytics configuration is deleted.
- ExpectedBucketOwner
-
- Type: string
The account ID of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP
403 (Access Denied)error. - Id
-
- Required: Yes
- Type: string
The ID that identifies the analytics configuration.
Result Syntax
[]
Result Details
Errors
There are no errors described for this operation.
DeleteBucketCors
$result = $client->deleteBucketCors([/* ... */]); $promise = $client->deleteBucketCorsAsync([/* ... */]);
Deletes the cors configuration information set for the bucket.
To use this operation, you must have permission to perform the s3:PutBucketCORS action. The bucket owner has this permission by default and can grant this permission to others.
For information about cors, see Enabling Cross-Origin Resource Sharing in the Amazon S3 User Guide.
Related Resources:
Parameter Syntax
$result = $client->deleteBucketCors([
'Bucket' => '<string>', // REQUIRED
'ExpectedBucketOwner' => '<string>',
]);
Parameter Details
Members
- Bucket
-
- Required: Yes
- Type: string
Specifies the bucket whose
corsconfiguration is being deleted. - ExpectedBucketOwner
-
- Type: string
The account ID of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP
403 (Access Denied)error.
Result Syntax
[]
Result Details
Errors
There are no errors described for this operation.
Examples
Example 1: To delete cors configuration on a bucket.
The following example deletes CORS configuration on a bucket.
$result = $client->deleteBucketCors([
'Bucket' => 'examplebucket',
]);
DeleteBucketEncryption
$result = $client->deleteBucketEncryption([/* ... */]); $promise = $client->deleteBucketEncryptionAsync([/* ... */]);
This implementation of the DELETE action removes default encryption from the bucket. For information about the Amazon S3 default encryption feature, see Amazon S3 Default Bucket Encryption in the Amazon S3 User Guide.
To use this operation, you must have permissions to perform the s3:PutEncryptionConfiguration action. The bucket owner has this permission by default. The bucket owner 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 in the Amazon S3 User Guide.
Related Resources
Parameter Syntax
$result = $client->deleteBucketEncryption([
'Bucket' => '<string>', // REQUIRED
'ExpectedBucketOwner' => '<string>',
]);
Parameter Details
Members
- Bucket
-
- Required: Yes
- Type: string
The name of the bucket containing the server-side encryption configuration to delete.
- ExpectedBucketOwner
-
- Type: string
The account ID of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP
403 (Access Denied)error.
Result Syntax
[]
Result Details
Errors
There are no errors described for this operation.
DeleteBucketIntelligentTieringConfiguration
$result = $client->deleteBucketIntelligentTieringConfiguration([/* ... */]); $promise = $client->deleteBucketIntelligentTieringConfigurationAsync([/* ... */]);
Deletes the S3 Intelligent-Tiering configuration from the specified bucket.
The S3 Intelligent-Tiering storage class is designed to optimize storage costs by automatically moving data to the most cost-effective storage access tier, without performance impact or operational overhead. S3 Intelligent-Tiering delivers automatic cost savings in three low latency and high throughput access tiers. To get the lowest storage cost on data that can be accessed in minutes to hours, you can choose to activate additional archiving capabilities.
The S3 Intelligent-Tiering storage class is the ideal storage class for data with unknown, changing, or unpredictable access patterns, independent of object size or retention period. If the size of an object is less than 128 KB, it is not monitored and not eligible for auto-tiering. Smaller objects can be stored, but they are always charged at the Frequent Access tier rates in the S3 Intelligent-Tiering storage class.
For more information, see Storage class for automatically optimizing frequently and infrequently accessed objects.
Operations related to DeleteBucketIntelligentTieringConfiguration include:
Parameter Syntax
$result = $client->deleteBucketIntelligentTieringConfiguration([
'Bucket' => '<string>', // REQUIRED
'Id' => '<string>', // REQUIRED
]);
Parameter Details
Members
- Bucket
-
- Required: Yes
- Type: string
The name of the Amazon S3 bucket whose configuration you want to modify or retrieve.
- Id
-
- Required: Yes
- Type: string
The ID used to identify the S3 Intelligent-Tiering configuration.
Result Syntax
[]
Result Details
Errors
There are no errors described for this operation.
DeleteBucketInventoryConfiguration
$result = $client->deleteBucketInventoryConfiguration([/* ... */]); $promise = $client->deleteBucketInventoryConfigurationAsync([/* ... */]);
Deletes an inventory configuration (identified by the inventory ID) from the bucket.
To use this operation, you must have permissions to perform the s3:PutInventoryConfiguration action. The bucket owner has this permission by default. The bucket owner 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.
For information about the Amazon S3 inventory feature, see Amazon S3 Inventory.
Operations related to DeleteBucketInventoryConfiguration include:
Parameter Syntax
$result = $client->deleteBucketInventoryConfiguration([
'Bucket' => '<string>', // REQUIRED
'ExpectedBucketOwner' => '<string>',
'Id' => '<string>', // REQUIRED
]);
Parameter Details
Members
- Bucket
-
- Required: Yes
- Type: string
The name of the bucket containing the inventory configuration to delete.
- ExpectedBucketOwner
-
- Type: string
The account ID of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP
403 (Access Denied)error. - Id
-
- Required: Yes
- Type: string
The ID used to identify the inventory configuration.
Result Syntax
[]
Result Details
Errors
There are no errors described for this operation.
DeleteBucketLifecycle
$result = $client->deleteBucketLifecycle([/* ... */]); $promise = $client->deleteBucketLifecycleAsync([/* ... */]);
Deletes the lifecycle configuration from the specified bucket. Amazon S3 removes all the lifecycle configuration rules in the lifecycle subresource associated with the bucket. Your objects never expire, and Amazon S3 no longer automatically deletes any objects on the basis of rules contained in the deleted lifecycle configuration.
To use this operation, you must have permission to perform the s3:PutLifecycleConfiguration action. By default, the bucket owner has this permission and the bucket owner can grant this permission to others.
There is usually some time lag before lifecycle configuration deletion is fully propagated to all the Amazon S3 systems.
For more information about the object expiration, see Elements to Describe Lifecycle Actions.
Related actions include:
Parameter Syntax
$result = $client->deleteBucketLifecycle([
'Bucket' => '<string>', // REQUIRED
'ExpectedBucketOwner' => '<string>',
]);
Parameter Details
Members
- Bucket
-
- Required: Yes
- Type: string
The bucket name of the lifecycle to delete.
- ExpectedBucketOwner
-
- Type: string
The account ID of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP
403 (Access Denied)error.
Result Syntax
[]
Result Details
Errors
There are no errors described for this operation.
Examples
Example 1: To delete lifecycle configuration on a bucket.
The following example deletes lifecycle configuration on a bucket.
$result = $client->deleteBucketLifecycle([
'Bucket' => 'examplebucket',
]);
DeleteBucketMetricsConfiguration
$result = $client->deleteBucketMetricsConfiguration([/* ... */]); $promise = $client->deleteBucketMetricsConfigurationAsync([/* ... */]);
Deletes a metrics configuration for the Amazon CloudWatch request metrics (specified by the metrics configuration ID) from the bucket. Note that this doesn’t include the daily storage metrics.
To use this operation, you must have permissions to perform the s3:PutMetricsConfiguration action. The bucket owner has this permission by default. The bucket owner 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.
For information about CloudWatch request metrics for Amazon S3, see Monitoring Metrics with Amazon CloudWatch.
The following operations are related to DeleteBucketMetricsConfiguration:
Parameter Syntax
$result = $client->deleteBucketMetricsConfiguration([
'Bucket' => '<string>', // REQUIRED
'ExpectedBucketOwner' => '<string>',
'Id' => '<string>', // REQUIRED
]);
Parameter Details
Members
- Bucket
-
- Required: Yes
- Type: string
The name of the bucket containing the metrics configuration to delete.
- ExpectedBucketOwner
-
- Type: string
The account ID of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP
403 (Access Denied)error. - Id
-
- Required: Yes
- Type: string
The ID used to identify the metrics configuration.
Result Syntax
[]
Result Details
Errors
There are no errors described for this operation.
DeleteBucketOwnershipControls
$result = $client->deleteBucketOwnershipControls([/* ... */]); $promise = $client->deleteBucketOwnershipControlsAsync([/* ... */]);
Removes OwnershipControls for an Amazon S3 bucket. To use this operation, you must have the s3:PutBucketOwnershipControls permission. For more information about Amazon S3 permissions, see Specifying Permissions in a Policy.
For information about Amazon S3 Object Ownership, see Using Object Ownership.
The following operations are related to DeleteBucketOwnershipControls:
Parameter Syntax
$result = $client->deleteBucketOwnershipControls([
'Bucket' => '<string>', // REQUIRED
'ExpectedBucketOwner' => '<string>',
]);
Parameter Details
Members
- Bucket
-
- Required: Yes
- Type: string
The Amazon S3 bucket whose
OwnershipControlsyou want to delete. - ExpectedBucketOwner
-
- Type: string
The account ID of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP
403 (Access Denied)error.
Result Syntax
[]
Result Details
Errors
There are no errors described for this operation.
DeleteBucketPolicy
$result = $client->deleteBucketPolicy([/* ... */]); $promise = $client->deleteBucketPolicyAsync([/* ... */]);
This implementation of the DELETE action uses the policy subresource to delete the policy of a specified bucket. If you are using an identity other than the root user of the Amazon Web Services account that owns the bucket, the calling identity must have the DeleteBucketPolicy permissions on the specified bucket and belong to the bucket owner’s account to use this operation.
If you don’t have DeleteBucketPolicy permissions, Amazon S3 returns a 403 Access Denied error. If you have the correct permissions, but you’re not using an identity that belongs to the bucket owner’s account, Amazon S3 returns a 405 Method Not Allowed error.
As a security precaution, the root user of the Amazon Web Services account that owns a bucket can always use this operation, even if the policy explicitly denies the root user the ability to perform this action.
For more information about bucket policies, see Using Bucket Policies and UserPolicies.
The following operations are related to DeleteBucketPolicy
Parameter Syntax
$result = $client->deleteBucketPolicy([
'Bucket' => '<string>', // REQUIRED
'ExpectedBucketOwner' => '<string>',
]);
Parameter Details
Members
- Bucket
-
- Required: Yes
- Type: string
The bucket name.
- ExpectedBucketOwner
-
- Type: string
The account ID of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP
403 (Access Denied)error.
Result Syntax
[]
Result Details
Errors
There are no errors described for this operation.
Examples
Example 1: To delete bucket policy
The following example deletes bucket policy on the specified bucket.
$result = $client->deleteBucketPolicy([
'Bucket' => 'examplebucket',
]);
DeleteBucketReplication
$result = $client->deleteBucketReplication([/* ... */]); $promise = $client->deleteBucketReplicationAsync([/* ... */]);
Deletes the replication configuration from the bucket.
To use this operation, you must have permissions to perform the s3:PutReplicationConfiguration action. The bucket owner has these permissions by default and can grant it to others. For more information about permissions, see Permissions Related to Bucket Subresource Operations and Managing Access Permissions to Your Amazon S3 Resources.
It can take a while for the deletion of a replication configuration to fully propagate.
For information about replication configuration, see Replication in the Amazon S3 User Guide.
The following operations are related to DeleteBucketReplication:
Parameter Syntax
$result = $client->deleteBucketReplication([
'Bucket' => '<string>', // REQUIRED
'ExpectedBucketOwner' => '<string>',
]);
Parameter Details
Members
- Bucket
-
- Required: Yes
- Type: string
The bucket name.
- ExpectedBucketOwner
-
- Type: string
The account ID of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP
403 (Access Denied)error.
Result Syntax
[]
Result Details
Errors
There are no errors described for this operation.
Examples
Example 1: To delete bucket replication configuration
The following example deletes replication configuration set on bucket.
$result = $client->deleteBucketReplication([
'Bucket' => 'example',
]);
DeleteBucketTagging
$result = $client->deleteBucketTagging([/* ... */]); $promise = $client->deleteBucketTaggingAsync([/* ... */]);
Deletes the tags from the bucket.
To use this operation, you must have permission to perform the s3:PutBucketTagging action. By default, the bucket owner has this permission and can grant this permission to others.
The following operations are related to DeleteBucketTagging:
Parameter Syntax
$result = $client->deleteBucketTagging([
'Bucket' => '<string>', // REQUIRED
'ExpectedBucketOwner' => '<string>',
]);
Parameter Details
Members
- Bucket
-
- Required: Yes
- Type: string
The bucket that has the tag set to be removed.
- ExpectedBucketOwner
-
- Type: string
The account ID of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP
403 (Access Denied)error.
Result Syntax
[]
Result Details
Errors
There are no errors described for this operation.
Examples
Example 1: To delete bucket tags
The following example deletes bucket tags.
$result = $client->deleteBucketTagging([
'Bucket' => 'examplebucket',
]);
DeleteBucketWebsite
$result = $client->deleteBucketWebsite([/* ... */]); $promise = $client->deleteBucketWebsiteAsync([/* ... */]);
This action removes the website configuration for a bucket. Amazon S3 returns a 200 OK response upon successfully deleting a website configuration on the specified bucket. You will get a 200 OK response if the website configuration you are trying to delete does not exist on the bucket. Amazon S3 returns a 404 response if the bucket specified in the request does not exist.
This DELETE action 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.
For more information about hosting websites, see Hosting Websites on Amazon S3.
The following operations are related to DeleteBucketWebsite:
Parameter Syntax
$result = $client->deleteBucketWebsite([
'Bucket' => '<string>', // REQUIRED
'ExpectedBucketOwner' => '<string>',
]);
Parameter Details
Members
- Bucket
-
- Required: Yes
- Type: string
The bucket name for which you want to remove the website configuration.
- ExpectedBucketOwner
-
- Type: string
The account ID of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP
403 (Access Denied)error.
Result Syntax
[]
Result Details
Errors
There are no errors described for this operation.
Examples
Example 1: To delete bucket website configuration
The following example deletes bucket website configuration.
$result = $client->deleteBucketWebsite([
'Bucket' => 'examplebucket',
]);
DeleteObject
$result = $client->deleteObject([/* ... */]); $promise = $client->deleteObjectAsync([/* ... */]);
Removes the null version (if there is one) of an object and inserts a delete marker, which becomes the latest version of the object. If there isn’t a null version, Amazon S3 does not remove any objects but will still respond that the command was successful.
To remove a specific version, you must be the bucket owner and you must use the version Id subresource. Using this subresource permanently deletes the version. If the object deleted is a delete marker, Amazon S3 sets the response header, x-amz-delete-marker, to true.
If the object you want to delete is in a bucket where the bucket versioning configuration is MFA Delete enabled, you must include the x-amz-mfa request header in the DELETE versionId request. Requests that include x-amz-mfa must use HTTPS.
For more information about MFA Delete, see Using MFA Delete. To see sample requests that use versioning, see Sample Request.
You can delete objects by explicitly calling DELETE Object or configure its lifecycle (PutBucketLifecycle) to enable Amazon S3 to remove them for you. If you want to block users or accounts from removing or deleting objects from your bucket, you must deny them the s3:DeleteObject, s3:DeleteObjectVersion, and s3:PutLifeCycleConfiguration actions.
The following action is related to DeleteObject:
Parameter Syntax
$result = $client->deleteObject([
'Bucket' => '<string>', // REQUIRED
'BypassGovernanceRetention' => true || false,
'ExpectedBucketOwner' => '<string>',
'Key' => '<string>', // REQUIRED
'MFA' => '<string>',
'RequestPayer' => 'requester',
'VersionId' => '<string>',
]);
Parameter Details
Members
- Bucket
-
- Required: Yes
- Type: string
The bucket name of the bucket containing the object.
When using this action with an access point, you must direct requests to the access point hostname. The access point hostname takes the form AccessPointName–AccountId.s3-accesspoint.Region.amazonaws.com. When using this action with an access point through the Amazon Web Services SDKs, you provide the access point ARN in place of the bucket name. For more information about access point ARNs, see Using access points in the Amazon S3 User Guide.
When using this action with Amazon S3 on Outposts, you must direct requests to the S3 on Outposts hostname. The S3 on Outposts hostname takes the form AccessPointName–AccountId.outpostID.s3-outposts.Region.amazonaws.com. When using this action using S3 on Outposts through the Amazon Web Services SDKs, you provide the Outposts bucket ARN in place of the bucket name. For more information about S3 on Outposts ARNs, see Using S3 on Outposts in the Amazon S3 User Guide.
- BypassGovernanceRetention
-
- Type: boolean
Indicates whether S3 Object Lock should bypass Governance-mode restrictions to process this operation. To use this header, you must have the
s3:PutBucketPublicAccessBlockpermission. - ExpectedBucketOwner
-
- Type: string
The account ID of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP
403 (Access Denied)error. - Key
-
- Required: Yes
- Type: string
Key name of the object to delete.
- MFA
-
- Type: string
The concatenation of the authentication device’s serial number, a space, and the value that is displayed on your authentication device. Required to permanently delete a versioned object if versioning is configured with MFA delete enabled.
- RequestPayer
-
- Type: string
Confirms that the requester knows that they will be charged for the request. Bucket owners need not specify this parameter in their requests. For information about downloading objects from requester pays buckets, see Downloading Objects in Requestor Pays Buckets in the Amazon S3 User Guide.
- VersionId
-
- Type: string
VersionId used to reference a specific version of the object.
Result Syntax
[
'DeleteMarker' => true || false,
'RequestCharged' => 'requester',
'VersionId' => '<string>',
]
Result Details
Members
- DeleteMarker
-
- Type: boolean
Specifies whether the versioned object that was permanently deleted was (true) or was not (false) a delete marker.
- RequestCharged
-
- Type: string
If present, indicates that the requester was successfully charged for the request.
- VersionId
-
- Type: string
Returns the version ID of the delete marker created as a result of the DELETE operation.
Errors
There are no errors described for this operation.
Examples
Example 1: To delete an object
The following example deletes an object from an S3 bucket.
$result = $client->deleteObject([
'Bucket' => 'examplebucket',
'Key' => 'objectkey.jpg',
]);
Result syntax:
[ ]
Example 2: To delete an object (from a non-versioned bucket)
The following example deletes an object from a non-versioned bucket.
$result = $client->deleteObject([
'Bucket' => 'ExampleBucket',
'Key' => 'HappyFace.jpg',
]);
DeleteObjectTagging
$result = $client->deleteObjectTagging([/* ... */]); $promise = $client->deleteObjectTaggingAsync([/* ... */]);
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 DeleteBucketMetricsConfiguration:
Parameter Syntax
$result = $client->deleteObjectTagging([
'Bucket' => '<string>', // REQUIRED
'ExpectedBucketOwner' => '<string>',
'Key' => '<string>', // REQUIRED
'VersionId' => '<string>',
]);
Parameter Details
Members
- Bucket
-
- Required: Yes
- Type: string
The bucket name containing the objects from which to remove the tags.
When using this action with an access point, you must direct requests to the access point hostname. The access point hostname takes the form AccessPointName–AccountId.s3-accesspoint.Region.amazonaws.com. When using this action with an access point through the Amazon Web Services SDKs, you provide the access point ARN in place of the bucket name. For more information about access point ARNs, see Using access points in the Amazon S3 User Guide.
When using this action with Amazon S3 on Outposts, you must direct requests to the S3 on Outposts hostname. The S3 on Outposts hostname takes the form AccessPointName–AccountId.outpostID.s3-outposts.Region.amazonaws.com. When using this action using S3 on Outposts through the Amazon Web Services SDKs, you provide the Outposts bucket ARN in place of the bucket name. For more information about S3 on Outposts ARNs, see Using S3 on Outposts in the Amazon S3 User Guide.
- ExpectedBucketOwner
-
- Type: string
The account ID of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP
403 (Access Denied)error. - Key
-
- Required: Yes
- Type: string
The key that identifies the object in the bucket from which to remove all tags.
- VersionId
-
- Type: string
The versionId of the object that the tag-set will be removed from.
Result Syntax
[
'VersionId' => '<string>',
]
Result Details
Members
- VersionId
-
- Type: string
The versionId of the object the tag-set was removed from.
Errors
There are no errors described for this operation.
Examples
Example 1: To remove tag set from an object version
The following example removes tag set associated with the specified object version. The request specifies both the object key and object version.
$result = $client->deleteObjectTagging([
'Bucket' => 'examplebucket',
'Key' => 'HappyFace.jpg',
'VersionId' => 'ydlaNkwWm0SfKJR.T1b1fIdPRbldTYRI',
]);
Result syntax:
[
'VersionId' => 'ydlaNkwWm0SfKJR.T1b1fIdPRbldTYRI',
]
Example 2: To remove tag set from an object
The following example removes tag set associated with the specified object. If the bucket is versioning enabled, the operation removes tag set from the latest object version.
$result = $client->deleteObjectTagging([
'Bucket' => 'examplebucket',
'Key' => 'HappyFace.jpg',
]);
Result syntax:
[
'VersionId' => 'null',
]
DeleteObjects
$result = $client->deleteObjects([/* ... */]); $promise = $client->deleteObjectsAsync([/* ... */]);
This action enables you to delete multiple objects from a bucket using a single HTTP request. If you know the object keys that you want to delete, then this action provides a suitable alternative to sending individual delete requests, reducing per-request overhead.
The request contains a list of up to 1000 keys that you want to delete. In the XML, you provide the object key names, and optionally, version IDs if you want to delete a specific version of the object from a versioning-enabled bucket. For each key, Amazon S3 performs a delete action and returns the result of that delete, success, or failure, in the response. Note that if the object specified in the request is not found, Amazon S3 returns the result as deleted.
The action supports two modes for the response: verbose and quiet. By default, the action uses verbose mode in which the response includes the result of deletion of each key in your request. In quiet mode the response includes only keys where the delete action encountered an error. For a successful deletion, the action does not return any information about the delete in the response body.
When performing this action on an MFA Delete enabled bucket, that attempts to delete any versioned objects, you must include an MFA token. If you do not provide one, the entire request will fail, even if there are non-versioned objects you are trying to delete. If you provide an invalid token, whether there are versioned keys in the request or not, the entire Multi-Object Delete request will fail. For information about MFA Delete, see MFA Delete.
Finally, the Content-MD5 header is required for all Multi-Object Delete requests. Amazon S3 uses the header value to ensure that your request body has not been altered in transit.
The following operations are related to DeleteObjects:
Parameter Syntax
$result = $client->deleteObjects([
'Bucket' => '<string>', // REQUIRED
'BypassGovernanceRetention' => true || false,
'Delete' => [ // REQUIRED
'Objects' => [ // REQUIRED
[
'Key' => '<string>', // REQUIRED
'VersionId' => '<string>',
],
// ...
],
'Quiet' => true || false,
],
'ExpectedBucketOwner' => '<string>',
'MFA' => '<string>',
'RequestPayer' => 'requester',
]);
Parameter Details
Members
- Bucket
-
- Required: Yes
- Type: string
The bucket name containing the objects to delete.
When using this action with an access point, you must direct requests to the access point hostname. The access point hostname takes the form AccessPointName–AccountId.s3-accesspoint.Region.amazonaws.com. When using this action with an access point through the Amazon Web Services SDKs, you provide the access point ARN in place of the bucket name. For more information about access point ARNs, see Using access points in the Amazon S3 User Guide.
When using this action with Amazon S3 on Outposts, you must direct requests to the S3 on Outposts hostname. The S3 on Outposts hostname takes the form AccessPointName–AccountId.outpostID.s3-outposts.Region.amazonaws.com. When using this action using S3 on Outposts through the Amazon Web Services SDKs, you provide the Outposts bucket ARN in place of the bucket name. For more information about S3 on Outposts ARNs, see Using S3 on Outposts in the Amazon S3 User Guide.
- BypassGovernanceRetention
-
- Type: boolean
Specifies whether you want to delete this object even if it has a Governance-type Object Lock in place. To use this header, you must have the
s3:PutBucketPublicAccessBlockpermission. - Delete
-
- Required: Yes
- Type: Delete structure
Container for the request.
- ExpectedBucketOwner
-
- Type: string
The account ID of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP
403 (Access Denied)error. - MFA
-
- Type: string
The concatenation of the authentication device’s serial number, a space, and the value that is displayed on your authentication device. Required to permanently delete a versioned object if versioning is configured with MFA delete enabled.
- RequestPayer
-
- Type: string
Confirms that the requester knows that they will be charged for the request. Bucket owners need not specify this parameter in their requests. For information about downloading objects from requester pays buckets, see Downloading Objects in Requestor Pays Buckets in the Amazon S3 User Guide.
Result Syntax
[
'Deleted' => [
[
'DeleteMarker' => true || false,
'DeleteMarkerVersionId' => '<string>',
'Key' => '<string>',
'VersionId' => '<string>',
],
// ...
],
'Errors' => [
[
'Code' => '<string>',
'Key' => '<string>',
'Message' => '<string>',
'VersionId' => '<string>',
],
// ...
],
'RequestCharged' => 'requester',
]
Result Details
Members
- Deleted
-
- Type: Array of DeletedObject structures
Container element for a successful delete. It identifies the object that was successfully deleted.
- Errors
-
- Type: Array of Error structures
Container for a failed delete action that describes the object that Amazon S3 attempted to delete and the error it encountered.
- RequestCharged
-
- Type: string
If present, indicates that the requester was successfully charged for the request.
Errors
There are no errors described for this operation.
Examples
Example 1: To delete multiple object versions from a versioned bucket
The following example deletes objects from a bucket. The request specifies object versions. S3 deletes specific object versions and returns the key and versions of deleted objects in the response.
$result = $client->deleteObjects([
'Bucket' => 'examplebucket',
'Delete' => [
'Objects' => [
[
'Key' => 'HappyFace.jpg',
'VersionId' => '2LWg7lQLnY41.maGB5Z6SWW.dcq0vx7b',
],
[
'Key' => 'HappyFace.jpg',
'VersionId' => 'yoz3HB.ZhCS_tKVEmIOr7qYyyAaZSKVd',
],
],
'Quiet' => ,
],
]);
Result syntax:
[
'Deleted' => [
[
'Key' => 'HappyFace.jpg',
'VersionId' => 'yoz3HB.ZhCS_tKVEmIOr7qYyyAaZSKVd',
],
[
'Key' => 'HappyFace.jpg',
'VersionId' => '2LWg7lQLnY41.maGB5Z6SWW.dcq0vx7b',
],
],
]
Example 2: To delete multiple objects from a versioned bucket
The following example deletes objects from a bucket. The bucket is versioned, and the request does not specify the object version to delete. In this case, all versions remain in the bucket and S3 adds a delete marker.
$result = $client->deleteObjects([
'Bucket' => 'examplebucket',
'Delete' => [
'Objects' => [
[
'Key' => 'objectkey1',
],
[
'Key' => 'objectkey2',
],
],
'Quiet' => ,
],
]);
Result syntax:
[
'Deleted' => [
[
'DeleteMarker' => true,
'DeleteMarkerVersionId' => 'A._w1z6EFiCF5uhtQMDal9JDkID9tQ7F',
'Key' => 'objectkey1',
],
[
'DeleteMarker' => true,
'DeleteMarkerVersionId' => 'iOd_ORxhkKe_e8G8_oSGxt2PjsCZKlkt',
'Key' => 'objectkey2',
],
],
]
DeletePublicAccessBlock
$result = $client->deletePublicAccessBlock([/* ... */]); $promise = $client->deletePublicAccessBlockAsync([/* ... */]);
Removes the PublicAccessBlock configuration for an Amazon S3 bucket. To use this operation, you must have the s3:PutBucketPublicAccessBlock permission. For more information about permissions, see Permissions Related to Bucket Subresource Operations and Managing Access Permissions to Your Amazon S3 Resources.
The following operations are related to DeletePublicAccessBlock:
Parameter Syntax
$result = $client->deletePublicAccessBlock([
'Bucket' => '<string>', // REQUIRED
'ExpectedBucketOwner' => '<string>',
]);
Parameter Details
Members
- Bucket
-
- Required: Yes
- Type: string
The Amazon S3 bucket whose
PublicAccessBlockconfiguration you want to delete. - ExpectedBucketOwner
-
- Type: string
The account ID of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP
403 (Access Denied)error.
Result Syntax
[]
Result Details
Errors
There are no errors described for this operation.
GetBucketAccelerateConfiguration
$result = $client->getBucketAccelerateConfiguration([/* ... */]); $promise = $client->getBucketAccelerateConfigurationAsync([/* ... */]);
This implementation of the GET action uses the accelerate subresource to return the Transfer Acceleration state of a bucket, which is either Enabled or Suspended. Amazon S3 Transfer Acceleration is a bucket-level feature that enables you to perform faster data transfers to and from Amazon S3.
To use this operation, you must have permission to perform the s3:GetAccelerateConfiguration action. The bucket owner has this permission by default. The bucket owner 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 in the Amazon S3 User Guide.
You set the Transfer Acceleration state of an existing bucket to Enabled or Suspended by using the PutBucketAccelerateConfiguration operation.
A GET accelerate request does not return a state value for a bucket that has no transfer acceleration state. A bucket has no Transfer Acceleration state if a state has never been set on the bucket.
For more information about transfer acceleration, see Transfer Acceleration in the Amazon S3 User Guide.
Related Resources
Parameter Syntax
$result = $client->getBucketAccelerateConfiguration([
'Bucket' => '<string>', // REQUIRED
'ExpectedBucketOwner' => '<string>',
]);
Parameter Details
Members
- Bucket
-
- Required: Yes
- Type: string
The name of the bucket for which the accelerate configuration is retrieved.
- ExpectedBucketOwner
-
- Type: string
The account ID of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP
403 (Access Denied)error.
Result Syntax
[
'Status' => 'Enabled|Suspended',
]
Result Details
Members
- Status
-
- Type: string
The accelerate configuration of the bucket.
Errors
There are no errors described for this operation.
GetBucketAcl
$result = $client->getBucketAcl([/* ... */]); $promise = $client->getBucketAclAsync([/* ... */]);
This implementation of the GET action uses the acl subresource to return the access control list (ACL) of a bucket. To use GET to return the ACL of the bucket, you must have READ_ACP access to the bucket. If READ_ACP permission is granted to the anonymous user, you can return the ACL of the bucket without using an authorization header.
If your bucket uses the bucket owner enforced setting for S3 Object Ownership, requests to read ACLs are still supported and return the bucket-owner-full-control ACL with the owner being the account that created the bucket. For more information, see Controlling object ownership and disabling ACLs in the Amazon S3 User Guide.
Related Resources
Parameter Syntax
$result = $client->getBucketAcl([
'Bucket' => '<string>', // REQUIRED
'ExpectedBucketOwner' => '<string>',
]);
Parameter Details
Members
- Bucket
-
- Required: Yes
- Type: string
Specifies the S3 bucket whose ACL is being requested.
- ExpectedBucketOwner
-
- Type: string
The account ID of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP
403 (Access Denied)error.
Result Syntax
[
'Grants' => [
[
'Grantee' => [
'DisplayName' => '<string>',
'EmailAddress' => '<string>',
'ID' => '<string>',
'Type' => 'CanonicalUser|AmazonCustomerByEmail|Group',
'URI' => '<string>',
],
'Permission' => 'FULL_CONTROL|WRITE|WRITE_ACP|READ|READ_ACP',
],
// ...
],
'Owner' => [
'DisplayName' => '<string>',
'ID' => '<string>',
],
]
Result Details
Members
Errors
There are no errors described for this operation.
GetBucketAnalyticsConfiguration
$result = $client->getBucketAnalyticsConfiguration([/* ... */]); $promise = $client->getBucketAnalyticsConfigurationAsync([/* ... */]);
This implementation of the GET action returns an analytics configuration (identified by the analytics configuration ID) from the bucket.
To use this operation, you must have permissions to perform the s3:GetAnalyticsConfiguration action. The bucket owner has this permission by default. The bucket owner 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 in the Amazon S3 User Guide.
For information about Amazon S3 analytics feature, see Amazon S3 Analytics – Storage Class Analysis in the Amazon S3 User Guide.
Related Resources
Parameter Syntax
$result = $client->getBucketAnalyticsConfiguration([
'Bucket' => '<string>', // REQUIRED
'ExpectedBucketOwner' => '<string>',
'Id' => '<string>', // REQUIRED
]);
Parameter Details
Members
- Bucket
-
- Required: Yes
- Type: string
The name of the bucket from which an analytics configuration is retrieved.
- ExpectedBucketOwner
-
- Type: string
The account ID of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP
403 (Access Denied)error. - Id
-
- Required: Yes
- Type: string
The ID that identifies the analytics configuration.
Result Syntax
[
'AnalyticsConfiguration' => [
'Filter' => [
'And' => [
'Prefix' => '<string>',
'Tags' => [
[
'Key' => '<string>',
'Value' => '<string>',
],
// ...
],
],
'Prefix' => '<string>',
'Tag' => [
'Key' => '<string>',
'Value' => '<string>',
],
],
'Id' => '<string>',
'StorageClassAnalysis' => [
'DataExport' => [
'Destination' => [
'S3BucketDestination' => [
'Bucket' => '<string>',
'BucketAccountId' => '<string>',
'Format' => 'CSV',
'Prefix' => '<string>',
],
],
'OutputSchemaVersion' => 'V_1',
],
],
],
]
Result Details
Members
- AnalyticsConfiguration
-
- Type: AnalyticsConfiguration structure
The configuration and any analyses for the analytics filter.
Errors
There are no errors described for this operation.
GetBucketCors
$result = $client->getBucketCors([/* ... */]); $promise = $client->getBucketCorsAsync([/* ... */]);
Returns the cors configuration information set for the bucket.
To use this operation, you must have permission to perform the s3:GetBucketCORS action. By default, the bucket owner has this permission and can grant it to others.
For more information about cors, see Enabling Cross-Origin Resource Sharing.
The following operations are related to GetBucketCors:
Parameter Syntax
$result = $client->getBucketCors([
'Bucket' => '<string>', // REQUIRED
'ExpectedBucketOwner' => '<string>',
]);
Parameter Details
Members
- Bucket
-
- Required: Yes
- Type: string
The bucket name for which to get the cors configuration.
- ExpectedBucketOwner
-
- Type: string
The account ID of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP
403 (Access Denied)error.
Result Syntax
[
'CORSRules' => [
[
'AllowedHeaders' => ['<string>', ...],
'AllowedMethods' => ['<string>', ...],
'AllowedOrigins' => ['<string>', ...],
'ExposeHeaders' => ['<string>', ...],
'ID' => '<string>',
'MaxAgeSeconds' => <integer>,
],
// ...
],
]
Result Details
Members
- CORSRules
-
- Type: Array of CORSRule structures
A set of origins and methods (cross-origin access that you want to allow). You can add up to 100 rules to the configuration.
Errors
There are no errors described for this operation.
Examples
Example 1: To get cors configuration set on a bucket
The following example returns cross-origin resource sharing (CORS) configuration set on a bucket.
$result = $client->getBucketCors([
'Bucket' => 'examplebucket',
]);
Result syntax:
[
'CORSRules' => [
[
'AllowedHeaders' => [
'Authorization',
],
'AllowedMethods' => [
'GET',
],
'AllowedOrigins' => [
'*',
],
'MaxAgeSeconds' => 3000,
],
],
]
GetBucketEncryption
$result = $client->getBucketEncryption([/* ... */]); $promise = $client->getBucketEncryptionAsync([/* ... */]);
Returns the default encryption configuration for an Amazon S3 bucket. If the bucket does not have a default encryption configuration, GetBucketEncryption returns ServerSideEncryptionConfigurationNotFoundError.
For information about the Amazon S3 default encryption feature, see Amazon S3 Default Bucket Encryption.
To use this operation, you must have permission to perform the s3:GetEncryptionConfiguration action. The bucket owner has this permission by default. The bucket owner 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.
The following operations are related to GetBucketEncryption:
Parameter Syntax
$result = $client->getBucketEncryption([
'Bucket' => '<string>', // REQUIRED
'ExpectedBucketOwner' => '<string>',
]);
Parameter Details
Members
- Bucket
-
- Required: Yes
- Type: string
The name of the bucket from which the server-side encryption configuration is retrieved.
- ExpectedBucketOwner
-
- Type: string
The account ID of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP
403 (Access Denied)error.
Result Syntax
[
'ServerSideEncryptionConfiguration' => [
'Rules' => [
[
'ApplyServerSideEncryptionByDefault' => [
'KMSMasterKeyID' => '<string>',
'SSEAlgorithm' => 'AES256|aws:kms',
],
'BucketKeyEnabled' => true || false,
],
// ...
],
],
]
Result Details
Members
- ServerSideEncryptionConfiguration
-
- Type: ServerSideEncryptionConfiguration structure
Specifies the default server-side-encryption configuration.
Errors
There are no errors described for this operation.
GetBucketIntelligentTieringConfiguration
$result = $client->getBucketIntelligentTieringConfiguration([/* ... */]); $promise = $client->getBucketIntelligentTieringConfigurationAsync([/* ... */]);
Gets the S3 Intelligent-Tiering configuration from the specified bucket.
The S3 Intelligent-Tiering storage class is designed to optimize storage costs by automatically moving data to the most cost-effective storage access tier, without performance impact or operational overhead. S3 Intelligent-Tiering delivers automatic cost savings in three low latency and high throughput access tiers. To get the lowest storage cost on data that can be accessed in minutes to hours, you can choose to activate additional archiving capabilities.
The S3 Intelligent-Tiering storage class is the ideal storage class for data with unknown, changing, or unpredictable access patterns, independent of object size or retention period. If the size of an object is less than 128 KB, it is not monitored and not eligible for auto-tiering. Smaller objects can be stored, but they are always charged at the Frequent Access tier rates in the S3 Intelligent-Tiering storage class.
For more information, see Storage class for automatically optimizing frequently and infrequently accessed objects.
Operations related to GetBucketIntelligentTieringConfiguration include:
Parameter Syntax
$result = $client->getBucketIntelligentTieringConfiguration([
'Bucket' => '<string>', // REQUIRED
'Id' => '<string>', // REQUIRED
]);
Parameter Details
Members
- Bucket
-
- Required: Yes
- Type: string
The name of the Amazon S3 bucket whose configuration you want to modify or retrieve.
- Id
-
- Required: Yes
- Type: string
The ID used to identify the S3 Intelligent-Tiering configuration.
Result Syntax
[
'IntelligentTieringConfiguration' => [
'Filter' => [
'And' => [
'Prefix' => '<string>',
'Tags' => [
[
'Key' => '<string>',
'Value' => '<string>',
],
// ...
],
],
'Prefix' => '<string>',
'Tag' => [
'Key' => '<string>',
'Value' => '<string>',
],
],
'Id' => '<string>',
'Status' => 'Enabled|Disabled',
'Tierings' => [
[
'AccessTier' => 'ARCHIVE_ACCESS|DEEP_ARCHIVE_ACCESS',
'Days' => <integer>,
],
// ...
],
],
]
Result Details
Members
- IntelligentTieringConfiguration
-
- Type: IntelligentTieringConfiguration structure
Container for S3 Intelligent-Tiering configuration.
Errors
There are no errors described for this operation.
GetBucketInventoryConfiguration
$result = $client->getBucketInventoryConfiguration([/* ... */]); $promise = $client->getBucketInventoryConfigurationAsync([/* ... */]);
Returns an inventory configuration (identified by the inventory configuration ID) from the bucket.
To use this operation, you must have permissions to perform the s3:GetInventoryConfiguration 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.
For information about the Amazon S3 inventory feature, see Amazon S3 Inventory.
The following operations are related to GetBucketInventoryConfiguration:
Parameter Syntax
$result = $client->getBucketInventoryConfiguration([
'Bucket' => '<string>', // REQUIRED
'ExpectedBucketOwner' => '<string>',
'Id' => '<string>', // REQUIRED
]);
Parameter Details
Members
- Bucket
-
- Required: Yes
- Type: string
The name of the bucket containing the inventory configuration to retrieve.
- ExpectedBucketOwner
-
- Type: string
The account ID of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP
403 (Access Denied)error. - Id
-
- Required: Yes
- Type: string
The ID used to identify the inventory configuration.
Result Syntax
[
'InventoryConfiguration' => [
'Destination' => [
'S3BucketDestination' => [
'AccountId' => '<string>',
'Bucket' => '<string>',
'Encryption' => [
'SSEKMS' => [
'KeyId' => '<string>',
],
'SSES3' => [
],
],
'Format' => 'CSV|ORC|Parquet',
'Prefix' => '<string>',
],
],
'Filter' => [
'Prefix' => '<string>',
],
'Id' => '<string>',
'IncludedObjectVersions' => 'All|Current',
'IsEnabled' => true || false,
'OptionalFields' => ['<string>', ...],
'Schedule' => [
'Frequency' => 'Daily|Weekly',
],
],
]
Result Details
Members
- InventoryConfiguration
-
- Type: InventoryConfiguration structure
Specifies the inventory configuration.
Errors
There are no errors described for this operation.
GetBucketLifecycle
$result = $client->getBucketLifecycle([/* ... */]); $promise = $client->getBucketLifecycleAsync([/* ... */]);
For an updated version of this API, see GetBucketLifecycleConfiguration. If you configured a bucket lifecycle using the filter element, you should see the updated version of this topic. This topic is provided for backward compatibility.
Returns the lifecycle configuration information set on the bucket. For information about lifecycle configuration, see Object Lifecycle Management.
To use this operation, you must have permission to perform the s3:GetLifecycleConfiguration action. The bucket owner has this permission by default. The bucket owner 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.
GetBucketLifecycle has the following special error:
- Error code:
NoSuchLifecycleConfiguration- Description: The lifecycle configuration does not exist.
- HTTP Status Code: 404 Not Found
- SOAP Fault Code Prefix: Client
The following operations are related to GetBucketLifecycle:
Parameter Syntax
$result = $client->getBucketLifecycle([
'Bucket' => '<string>', // REQUIRED
'ExpectedBucketOwner' => '<string>',
]);
Parameter Details
Members
- Bucket
-
- Required: Yes
- Type: string
The name of the bucket for which to get the lifecycle information.
- ExpectedBucketOwner
-
- Type: string
The account ID of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP
403 (Access Denied)error.
Result Syntax
[
'Rules' => [
[
'AbortIncompleteMultipartUpload' => [
'DaysAfterInitiation' => <integer>,
],
'Expiration' => [
'Date' => <DateTime>,
'Days' => <integer>,
'ExpiredObjectDeleteMarker' => true || false,
],
'ID' => '<string>',
'NoncurrentVersionExpiration' => [
'NewerNoncurrentVersions' => <integer>,
'NoncurrentDays' => <integer>,
],
'NoncurrentVersionTransition' => [
'NewerNoncurrentVersions' => <integer>,
'NoncurrentDays' => <integer>,
'StorageClass' => 'GLACIER|STANDARD_IA|ONEZONE_IA|INTELLIGENT_TIERING|DEEP_ARCHIVE|GLACIER_IR',
],
'Prefix' => '<string>',
'Status' => 'Enabled|Disabled',
'Transition' => [
'Date' => <DateTime>,
'Days' => <integer>,
'StorageClass' => 'GLACIER|STANDARD_IA|ONEZONE_IA|INTELLIGENT_TIERING|DEEP_ARCHIVE|GLACIER_IR',
],
],
// ...
],
]
Result Details
Members
- Rules
-
- Type: Array of Rule structures
Container for a lifecycle rule.
Errors
There are no errors described for this operation.
Examples
Example 1: To get a bucket acl
The following example gets ACL on the specified bucket.
$result = $client->getBucketLifecycle([
'Bucket' => 'acl1',
]);
Result syntax:
[
'Rules' => [
[
'Expiration' => [
'Days' => 1,
],
'ID' => 'delete logs',
'Prefix' => '123/',
'Status' => 'Enabled',
],
],
]
GetBucketLifecycleConfiguration
$result = $client->getBucketLifecycleConfiguration([/* ... */]); $promise = $client->getBucketLifecycleConfigurationAsync([/* ... */]);
Bucket lifecycle configuration now supports specifying a lifecycle rule using an object key name prefix, one or more object tags, or a combination of both. Accordingly, this section describes the latest API. The response describes the new filter element that you can use to specify a filter to select a subset of objects to which the rule applies. If you are using a previous version of the lifecycle configuration, it still works. For the earlier action, see GetBucketLifecycle.
Returns the lifecycle configuration information set on the bucket. For information about lifecycle configuration, see Object Lifecycle Management.
To use this operation, you must have permission to perform the s3:GetLifecycleConfiguration action. The bucket owner has this permission, by default. The bucket owner 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.
GetBucketLifecycleConfiguration has the following special error:
- Error code:
NoSuchLifecycleConfiguration- Description: The lifecycle configuration does not exist.
- HTTP Status Code: 404 Not Found
- SOAP Fault Code Prefix: Client
The following operations are related to GetBucketLifecycleConfiguration:
Parameter Syntax
$result = $client->getBucketLifecycleConfiguration([
'Bucket' => '<string>', // REQUIRED
'ExpectedBucketOwner' => '<string>',
]);
Parameter Details
Members
- Bucket
-
- Required: Yes
- Type: string
The name of the bucket for which to get the lifecycle information.
- ExpectedBucketOwner
-
- Type: string
The account ID of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP
403 (Access Denied)error.
Result Syntax
[
'Rules' => [
[
'AbortIncompleteMultipartUpload' => [
'DaysAfterInitiation' => <integer>,
],
'Expiration' => [
'Date' => <DateTime>,
'Days' => <integer>,
'ExpiredObjectDeleteMarker' => true || false,
],
'Filter' => [
'And' => [
'ObjectSizeGreaterThan' => <integer>,
'ObjectSizeLessThan' => <integer>,
'Prefix' => '<string>',
'Tags' => [
[
'Key' => '<string>',
'Value' => '<string>',
],
// ...
],
],
'ObjectSizeGreaterThan' => <integer>,
'ObjectSizeLessThan' => <integer>,
'Prefix' => '<string>',
'Tag' => [
'Key' => '<string>',
'Value' => '<string>',
],
],
'ID' => '<string>',
'NoncurrentVersionExpiration' => [
'NewerNoncurrentVersions' => <integer>,
'NoncurrentDays' => <integer>,
],
'NoncurrentVersionTransitions' => [
[
'NewerNoncurrentVersions' => <integer>,
'NoncurrentDays' => <integer>,
'StorageClass' => 'GLACIER|STANDARD_IA|ONEZONE_IA|INTELLIGENT_TIERING|DEEP_ARCHIVE|GLACIER_IR',
],
// ...
],
'Prefix' => '<string>',
'Status' => 'Enabled|Disabled',
'Transitions' => [
[
'Date' => <DateTime>,
'Days' => <integer>,
'StorageClass' => 'GLACIER|STANDARD_IA|ONEZONE_IA|INTELLIGENT_TIERING|DEEP_ARCHIVE|GLACIER_IR',
],
// ...
],
],
// ...
],
]
Result Details
Members
- Rules
-
- Type: Array of LifecycleRule structures
Container for a lifecycle rule.
Errors
There are no errors described for this operation.
Examples
Example 1: To get lifecycle configuration on a bucket
The following example retrieves lifecycle configuration on set on a bucket.
$result = $client->getBucketLifecycleConfiguration([
'Bucket' => 'examplebucket',
]);
Result syntax:
[
'Rules' => [
[
'ID' => 'Rule for TaxDocs/',
'Prefix' => 'TaxDocs',
'Status' => 'Enabled',
'Transitions' => [
[
'Days' => 365,
'StorageClass' => 'STANDARD_IA',
],
],
],
],
]
GetBucketLocation
$result = $client->getBucketLocation([/* ... */]); $promise = $client->getBucketLocationAsync([/* ... */]);
Returns the Region the bucket resides in. You set the bucket’s Region using the LocationConstraint request parameter in a CreateBucket request. For more information, see CreateBucket.
To use this implementation of the operation, you must be the bucket owner.
To use this API against an access point, provide the alias of the access point in place of the bucket name.
The following operations are related to GetBucketLocation:
Parameter Syntax
$result = $client->getBucketLocation([
'Bucket' => '<string>', // REQUIRED
'ExpectedBucketOwner' => '<string>',
]);
Parameter Details
Members
- Bucket
-
- Required: Yes
- Type: string
The name of the bucket for which to get the location.
- ExpectedBucketOwner
-
- Type: string
The account ID of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP
403 (Access Denied)error.
Result Syntax
[
'LocationConstraint' => 'ap-northeast-1|ap-southeast-2|ap-southeast-1|cn-north-1|eu-central-1|eu-west-1|us-east-1|us-west-1|us-west-2|sa-east-1',
]
Result Details
Members
- LocationConstraint
-
- Type: string
Specifies the Region where the bucket resides. For a list of all the Amazon S3 supported location constraints by Region, see Regions and Endpoints. Buckets in Region
us-east-1have a LocationConstraint ofnull.
Errors
There are no errors described for this operation.
Examples
Example 1: To get bucket location
The following example returns bucket location.
$result = $client->getBucketLocation([
'Bucket' => 'examplebucket',
]);
Result syntax:
[
'LocationConstraint' => 'us-west-2',
]
GetBucketLogging
$result = $client->getBucketLogging([/* ... */]); $promise = $client->getBucketLoggingAsync([/* ... */]);
Returns the logging status of a bucket and the permissions users have to view and modify that status. To use GET, you must be the bucket owner.
The following operations are related to GetBucketLogging:
Parameter Syntax
$result = $client->getBucketLogging([
'Bucket' => '<string>', // REQUIRED
'ExpectedBucketOwner' => '<string>',
]);
Parameter Details
Members
- Bucket
-
- Required: Yes
- Type: string
The bucket name for which to get the logging information.
- ExpectedBucketOwner
-
- Type: string
The account ID of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP
403 (Access Denied)error.
Result Syntax
[
'LoggingEnabled' => [
'TargetBucket' => '<string>',
'TargetGrants' => [
[
'Grantee' => [
'DisplayName' => '<string>',
'EmailAddress' => '<string>',
'ID' => '<string>',
'Type' => 'CanonicalUser|AmazonCustomerByEmail|Group',
'URI' => '<string>',
],
'Permission' => 'FULL_CONTROL|READ|WRITE',
],
// ...
],
'TargetPrefix' => '<string>',
],
]
Result Details
Members
- LoggingEnabled
-
- Type: LoggingEnabled structure
Describes where logs are stored and the prefix that Amazon S3 assigns to all log object keys for a bucket. For more information, see PUT Bucket logging in the Amazon S3 API Reference.
Errors
There are no errors described for this operation.
GetBucketMetricsConfiguration
$result = $client->getBucketMetricsConfiguration([/* ... */]); $promise = $client->getBucketMetricsConfigurationAsync([/* ... */]);
Gets a metrics configuration (specified by the metrics configuration ID) from the bucket. Note that this doesn’t include the daily storage metrics.
To use this operation, you must have permissions to perform the s3:GetMetricsConfiguration action. The bucket owner has this permission by default. The bucket owner 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.
For information about CloudWatch request metrics for Amazon S3, see Monitoring Metrics with Amazon CloudWatch.
The following operations are related to GetBucketMetricsConfiguration:
Parameter Syntax
$result = $client->getBucketMetricsConfiguration([
'Bucket' => '<string>', // REQUIRED
'ExpectedBucketOwner' => '<string>',
'Id' => '<string>', // REQUIRED
]);
Parameter Details
Members
- Bucket
-
- Required: Yes
- Type: string
The name of the bucket containing the metrics configuration to retrieve.
- ExpectedBucketOwner
-
- Type: string
The account ID of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP
403 (Access Denied)error. - Id
-
- Required: Yes
- Type: string
The ID used to identify the metrics configuration.
Result Syntax
[
'MetricsConfiguration' => [
'Filter' => [
'AccessPointArn' => '<string>',
'And' => [
'AccessPointArn' => '<string>',
'Prefix' => '<string>',
'Tags' => [
[
'Key' => '<string>',
'Value' => '<string>',
],
// ...
],
],
'Prefix' => '<string>',
'Tag' => [
'Key' => '<string>',
'Value' => '<string>',
],
],
'Id' => '<string>',
],
]
Result Details
Members
- MetricsConfiguration
-
- Type: MetricsConfiguration structure
Specifies the metrics configuration.
Errors
There are no errors described for this operation.
GetBucketNotification
$result = $client->getBucketNotification([/* ... */]); $promise = $client->getBucketNotificationAsync([/* ... */]);
No longer used, see GetBucketNotificationConfiguration.
Parameter Syntax
$result = $client->getBucketNotification([
'Bucket' => '<string>', // REQUIRED
'ExpectedBucketOwner' => '<string>',
]);
Parameter Details
Members
- Bucket
-
- Required: Yes
- Type: string
The name of the bucket for which to get the notification configuration.
- ExpectedBucketOwner
-
- Type: string
The account ID of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP
403 (Access Denied)error.
Result Syntax
[
'CloudFunctionConfiguration' => [
'CloudFunction' => '<string>',
'Event' => 's3:ReducedRedundancyLostObject|s3:ObjectCreated:*|s3:ObjectCreated:Put|s3:ObjectCreated:Post|s3:ObjectCreated:Copy|s3:ObjectCreated:CompleteMultipartUpload|s3:ObjectRemoved:*|s3:ObjectRemoved:Delete|s3:ObjectRemoved:DeleteMarkerCreated|s3:ObjectRestore:*|s3:ObjectRestore:Post|s3:ObjectRestore:Completed|s3:Replication:*|s3:Replication:OperationFailedReplication|s3:Replication:OperationNotTracked|s3:Replication:OperationMissedThreshold|s3:Replication:OperationReplicatedAfterThreshold|s3:ObjectRestore:Delete|s3:LifecycleTransition|s3:IntelligentTiering|s3:ObjectAcl:Put|s3:LifecycleExpiration:*|s3:LifecycleExpiration:Delete|s3:LifecycleExpiration:DeleteMarkerCreated|s3:ObjectTagging:*|s3:ObjectTagging:Put|s3:ObjectTagging:Delete',
'Events' => ['<string>', ...],
'Id' => '<string>',
'InvocationRole' => '<string>',
],
'QueueConfiguration' => [
'Event' => 's3:ReducedRedundancyLostObject|s3:ObjectCreated:*|s3:ObjectCreated:Put|s3:ObjectCreated:Post|s3:ObjectCreated:Copy|s3:ObjectCreated:CompleteMultipartUpload|s3:ObjectRemoved:*|s3:ObjectRemoved:Delete|s3:ObjectRemoved:DeleteMarkerCreated|s3:ObjectRestore:*|s3:ObjectRestore:Post|s3:ObjectRestore:Completed|s3:Replication:*|s3:Replication:OperationFailedReplication|s3:Replication:OperationNotTracked|s3:Replication:OperationMissedThreshold|s3:Replication:OperationReplicatedAfterThreshold|s3:ObjectRestore:Delete|s3:LifecycleTransition|s3:IntelligentTiering|s3:ObjectAcl:Put|s3:LifecycleExpiration:*|s3:LifecycleExpiration:Delete|s3:LifecycleExpiration:DeleteMarkerCreated|s3:ObjectTagging:*|s3:ObjectTagging:Put|s3:ObjectTagging:Delete',
'Events' => ['<string>', ...],
'Id' => '<string>',
'Queue' => '<string>',
],
'TopicConfiguration' => [
'Event' => 's3:ReducedRedundancyLostObject|s3:ObjectCreated:*|s3:ObjectCreated:Put|s3:ObjectCreated:Post|s3:ObjectCreated:Copy|s3:ObjectCreated:CompleteMultipartUpload|s3:ObjectRemoved:*|s3:ObjectRemoved:Delete|s3:ObjectRemoved:DeleteMarkerCreated|s3:ObjectRestore:*|s3:ObjectRestore:Post|s3:ObjectRestore:Completed|s3:Replication:*|s3:Replication:OperationFailedReplication|s3:Replication:OperationNotTracked|s3:Replication:OperationMissedThreshold|s3:Replication:OperationReplicatedAfterThreshold|s3:ObjectRestore:Delete|s3:LifecycleTransition|s3:IntelligentTiering|s3:ObjectAcl:Put|s3:LifecycleExpiration:*|s3:LifecycleExpiration:Delete|s3:LifecycleExpiration:DeleteMarkerCreated|s3:ObjectTagging:*|s3:ObjectTagging:Put|s3:ObjectTagging:Delete',
'Events' => ['<string>', ...],
'Id' => '<string>',
'Topic' => '<string>',
],
]
Result Details
Members
- CloudFunctionConfiguration
-
- Type: CloudFunctionConfiguration structure
Container for specifying the Lambda notification configuration.
- QueueConfiguration
-
- Type: QueueConfigurationDeprecated structure
This data type is deprecated. This data type specifies the configuration for publishing messages to an Amazon Simple Queue Service (Amazon SQS) queue when Amazon S3 detects specified events.
- TopicConfiguration
-
- Type: TopicConfigurationDeprecated structure
This data type is deprecated. A container for specifying the configuration for publication of messages to an Amazon Simple Notification Service (Amazon SNS) topic when Amazon S3 detects specified events.
Errors
There are no errors described for this operation.
Examples
Example 1: To get notification configuration set on a bucket
The following example returns notification configuration set on a bucket.
$result = $client->getBucketNotification([
'Bucket' => 'examplebucket',
]);
Result syntax:
[
'QueueConfiguration' => [
'Event' => 's3:ObjectCreated:Put',
'Events' => [
's3:ObjectCreated:Put',
],
'Id' => 'MDQ2OGQ4NDEtOTBmNi00YTM4LTk0NzYtZDIwN2I3NWQ1NjIx',
'Queue' => 'arn:aws:sqs:us-east-1:acct-id:S3ObjectCreatedEventQueue',
],
'TopicConfiguration' => [
'Event' => 's3:ObjectCreated:Copy',
'Events' => [
's3:ObjectCreated:Copy',
],
'Id' => 'YTVkMWEzZGUtNTY1NS00ZmE2LWJjYjktMmRlY2QwODFkNTJi',
'Topic' => 'arn:aws:sns:us-east-1:acct-id:S3ObjectCreatedEventTopic',
],
]
Example 2: To get notification configuration set on a bucket
The following example returns notification configuration set on a bucket.
$result = $client->getBucketNotification([
'Bucket' => 'examplebucket',
]);
Result syntax:
[
'QueueConfiguration' => [
'Event' => 's3:ObjectCreated:Put',
'Events' => [
's3:ObjectCreated:Put',
],
'Id' => 'MDQ2OGQ4NDEtOTBmNi00YTM4LTk0NzYtZDIwN2I3NWQ1NjIx',
'Queue' => 'arn:aws:sqs:us-east-1:acct-id:S3ObjectCreatedEventQueue',
],
'TopicConfiguration' => [
'Event' => 's3:ObjectCreated:Copy',
'Events' => [
's3:ObjectCreated:Copy',
],
'Id' => 'YTVkMWEzZGUtNTY1NS00ZmE2LWJjYjktMmRlY2QwODFkNTJi',
'Topic' => 'arn:aws:sns:us-east-1:acct-id:S3ObjectCreatedEventTopic',
],
]
GetBucketNotificationConfiguration
$result = $client->getBucketNotificationConfiguration([/* ... */]); $promise = $client->getBucketNotificationConfigurationAsync([/* ... */]);
Returns the notification configuration of a bucket.
If notifications are not enabled on the bucket, the action returns an empty NotificationConfiguration element.
By default, you must be the bucket owner to read the notification configuration of a bucket. However, the bucket owner can use a bucket policy to grant permission to other users to read this configuration with the s3:GetBucketNotification permission.
For more information about setting and reading the notification configuration on a bucket, see Setting Up Notification of Bucket Events. For more information about bucket policies, see Using Bucket Policies.
The following action is related to GetBucketNotification:
Parameter Syntax
$result = $client->getBucketNotificationConfiguration([
'Bucket' => '<string>', // REQUIRED
'ExpectedBucketOwner' => '<string>',
]);
Parameter Details
Members
- Bucket
-
- Required: Yes
- Type: string
The name of the bucket for which to get the notification configuration.
- ExpectedBucketOwner
-
- Type: string
The account ID of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP
403 (Access Denied)error.
Result Syntax
[
'EventBridgeConfiguration' => [
],
'LambdaFunctionConfigurations' => [
[
'Events' => ['<string>', ...],
'Filter' => [
'Key' => [
'FilterRules' => [
[
'Name' => 'prefix|suffix',
'Value' => '<string>',
],
// ...
],
],
],
'Id' => '<string>',
'LambdaFunctionArn' => '<string>',
],
// ...
],
'QueueConfigurations' => [
[
'Events' => ['<string>', ...],
'Filter' => [
'Key' => [
'FilterRules' => [
[
'Name' => 'prefix|suffix',
'Value' => '<string>',
],
// ...
],
],
],
'Id' => '<string>',
'QueueArn' => '<string>',
],
// ...
],
'TopicConfigurations' => [
[
'Events' => ['<string>', ...],
'Filter' => [
'Key' => [
'FilterRules' => [
[
'Name' => 'prefix|suffix',
'Value' => '<string>',
],
// ...
],
],
],
'Id' => '<string>',
'TopicArn' => '<string>',
],
// ...
],
]
Result Details
Members
- EventBridgeConfiguration
-
- Type: EventBridgeConfiguration structure
Enables delivery of events to Amazon EventBridge.
- LambdaFunctionConfigurations
-
- Type: Array of LambdaFunctionConfiguration structures
Describes the Lambda functions to invoke and the events for which to invoke them.
- QueueConfigurations
-
- Type: Array of QueueConfiguration structures
The Amazon Simple Queue Service queues to publish messages to and the events for which to publish messages.
- TopicConfigurations
-
- Type: Array of TopicConfiguration structures
The topic to which notifications are sent and the events for which notifications are generated.
Errors
There are no errors described for this operation.
GetBucketOwnershipControls
$result = $client->getBucketOwnershipControls([/* ... */]); $promise = $client->getBucketOwnershipControlsAsync([/* ... */]);
Retrieves OwnershipControls for an Amazon S3 bucket. To use this operation, you must have the s3:GetBucketOwnershipControls permission. For more information about Amazon S3 permissions, see Specifying permissions in a policy.
For information about Amazon S3 Object Ownership, see Using Object Ownership.
The following operations are related to GetBucketOwnershipControls:
Parameter Syntax
$result = $client->getBucketOwnershipControls([
'Bucket' => '<string>', // REQUIRED
'ExpectedBucketOwner' => '<string>',
]);
Parameter Details
Members
- Bucket
-
- Required: Yes
- Type: string
The name of the Amazon S3 bucket whose
OwnershipControlsyou want to retrieve. - ExpectedBucketOwner
-
- Type: string
The account ID of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP
403 (Access Denied)error.
Result Syntax
[
'OwnershipControls' => [
'Rules' => [
[
'ObjectOwnership' => 'BucketOwnerPreferred|ObjectWriter|BucketOwnerEnforced',
],
// ...
],
],
]
Result Details
Members
- OwnershipControls
-
- Type: OwnershipControls structure
The
OwnershipControls(BucketOwnerEnforced, BucketOwnerPreferred, or ObjectWriter) currently in effect for this Amazon S3 bucket.
Errors
There are no errors described for this operation.
GetBucketPolicy
$result = $client->getBucketPolicy([/* ... */]); $promise = $client->getBucketPolicyAsync([/* ... */]);
Returns the policy of a specified bucket. If you are using an identity other than the root user of the Amazon Web Services account that owns the bucket, the calling identity must have the GetBucketPolicy permissions on the specified bucket and belong to the bucket owner’s account in order to use this operation.
If you don’t have GetBucketPolicy permissions, Amazon S3 returns a 403 Access Denied error. If you have the correct permissions, but you’re not using an identity that belongs to the bucket owner’s account, Amazon S3 returns a 405 Method Not Allowed error.
As a security precaution, the root user of the Amazon Web Services account that owns a bucket can always use this operation, even if the policy explicitly denies the root user the ability to perform this action.
For more information about bucket policies, see Using Bucket Policies and User Policies.
The following action is related to GetBucketPolicy:
Parameter Syntax
$result = $client->getBucketPolicy([
'Bucket' => '<string>', // REQUIRED
'ExpectedBucketOwner' => '<string>',
]);
Parameter Details
Members
- Bucket
-
- Required: Yes
- Type: string
The bucket name for which to get the bucket policy.
- ExpectedBucketOwner
-
- Type: string
The account ID of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP
403 (Access Denied)error.
Result Syntax
[
'Policy' => '<string>',
]
Result Details
Members
- Policy
-
- Type: string
The bucket policy as a JSON document.
Errors
There are no errors described for this operation.
Examples
Example 1: To get bucket policy
The following example returns bucket policy associated with a bucket.
$result = $client->getBucketPolicy([
'Bucket' => 'examplebucket',
]);
Result syntax:
[
'Policy' => '{"Version":"2008-10-17","Id":"LogPolicy","Statement":[{"Sid":"Enables the log delivery group to publish logs to your bucket ","Effect":"Allow","Principal":{"AWS":"111122223333"},"Action":["s3:GetBucketAcl","s3:GetObjectAcl","s3:PutObject"],"Resource":["arn:aws:s3:::policytest1/*","arn:aws:s3:::policytest1"]}]}',
]
GetBucketPolicyStatus
$result = $client->getBucketPolicyStatus([/* ... */]); $promise = $client->getBucketPolicyStatusAsync([/* ... */]);
Retrieves the policy status for an Amazon S3 bucket, indicating whether the bucket is public. In order to use this operation, you must have the s3:GetBucketPolicyStatus permission. For more information about Amazon S3 permissions, see Specifying Permissions in a Policy.
For more information about when Amazon S3 considers a bucket public, see The Meaning of “Public”.
The following operations are related to GetBucketPolicyStatus:
Parameter Syntax
$result = $client->getBucketPolicyStatus([
'Bucket' => '<string>', // REQUIRED
'ExpectedBucketOwner' => '<string>',
]);
Parameter Details
Members
- Bucket
-
- Required: Yes
- Type: string
The name of the Amazon S3 bucket whose policy status you want to retrieve.
- ExpectedBucketOwner
-
- Type: string
The account ID of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP
403 (Access Denied)error.
Result Syntax
[
'PolicyStatus' => [
'IsPublic' => true || false,
],
]
Result Details
Members
- PolicyStatus
-
- Type: PolicyStatus structure
The policy status for the specified bucket.
Errors
There are no errors described for this operation.
GetBucketReplication
$result = $client->getBucketReplication([/* ... */]); $promise = $client->getBucketReplicationAsync([/* ... */]);
Returns the replication configuration of a bucket.
It can take a while to propagate the put or delete a replication configuration to all Amazon S3 systems. Therefore, a get request soon after put or delete can return a wrong result.
For information about replication configuration, see Replication in the Amazon S3 User Guide.
This action requires permissions for the s3:GetReplicationConfiguration action. For more information about permissions, see Using Bucket Policies and User Policies.
If you include the Filter element in a replication configuration, you must also include the DeleteMarkerReplication and Priority elements. The response also returns those elements.
For information about GetBucketReplication errors, see List of replication-related error codes
The following operations are related to GetBucketReplication:
Parameter Syntax
$result = $client->getBucketReplication([
'Bucket' => '<string>', // REQUIRED
'ExpectedBucketOwner' => '<string>',
]);
Parameter Details
Members
- Bucket
-
- Required: Yes
- Type: string
The bucket name for which to get the replication information.
- ExpectedBucketOwner
-
- Type: string
The account ID of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP
403 (Access Denied)error.
Result Syntax
[
'ReplicationConfiguration' => [
'Role' => '<string>',
'Rules' => [
[
'DeleteMarkerReplication' => [
'Status' => 'Enabled|Disabled',
],
'Destination' => [
'AccessControlTranslation' => [
'Owner' => 'Destination',
],
'Account' => '<string>',
'Bucket' => '<string>',
'EncryptionConfiguration' => [
'ReplicaKmsKeyID' => '<string>',
],
'Metrics' => [
'EventThreshold' => [
'Minutes' => <integer>,
],
'Status' => 'Enabled|Disabled',
],
'ReplicationTime' => [
'Status' => 'Enabled|Disabled',
'Time' => [
'Minutes' => <integer>,
],
],
'StorageClass' => 'STANDARD|REDUCED_REDUNDANCY|STANDARD_IA|ONEZONE_IA|INTELLIGENT_TIERING|GLACIER|DEEP_ARCHIVE|OUTPOSTS|GLACIER_IR',
],
'ExistingObjectReplication' => [
'Status' => 'Enabled|Disabled',
],
'Filter' => [
'And' => [
'Prefix' => '<string>',
'Tags' => [
[
'Key' => '<string>',
'Value' => '<string>',
],
// ...
],
],
'Prefix' => '<string>',
'Tag' => [
'Key' => '<string>',
'Value' => '<string>',
],
],
'ID' => '<string>',
'Prefix' => '<string>',
'Priority' => <integer>,
'SourceSelectionCriteria' => [
'ReplicaModifications' => [
'Status' => 'Enabled|Disabled',
],
'SseKmsEncryptedObjects' => [
'Status' => 'Enabled|Disabled',
],
],
'Status' => 'Enabled|Disabled',
],
// ...
],
],
]
Result Details
Members
- ReplicationConfiguration
-
- Type: ReplicationConfiguration structure
A container for replication rules. You can add up to 1,000 rules. The maximum size of a replication configuration is 2 MB.
Errors
There are no errors described for this operation.
Examples
Example 1: To get replication configuration set on a bucket
The following example returns replication configuration set on a bucket.
$result = $client->getBucketReplication([
'Bucket' => 'examplebucket',
]);
Result syntax:
[
'ReplicationConfiguration' => [
'Role' => 'arn:aws:iam::acct-id:role/example-role',
'Rules' => [
[
'Destination' => [
'Bucket' => 'arn:aws:s3:::destination-bucket',
],
'ID' => 'MWIwNTkwZmItMTE3MS00ZTc3LWJkZDEtNzRmODQwYzc1OTQy',
'Prefix' => 'Tax',
'Status' => 'Enabled',
],
],
],
]
GetBucketRequestPayment
$result = $client->getBucketRequestPayment([/* ... */]); $promise = $client->getBucketRequestPaymentAsync([/* ... */]);
Returns the request payment configuration of a bucket. To use this version of the operation, you must be the bucket owner. For more information, see Requester Pays Buckets.
The following operations are related to GetBucketRequestPayment:
Parameter Syntax
$result = $client->getBucketRequestPayment([
'Bucket' => '<string>', // REQUIRED
'ExpectedBucketOwner' => '<string>',
]);
Parameter Details
Members
- Bucket
-
- Required: Yes
- Type: string
The name of the bucket for which to get the payment request configuration
- ExpectedBucketOwner
-
- Type: string
The account ID of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP
403 (Access Denied)error.
Result Syntax
[
'Payer' => 'Requester|BucketOwner',
]
Result Details
Members
- Payer
-
- Type: string
Specifies who pays for the download and request fees.
Errors
There are no errors described for this operation.
Examples
Example 1: To get bucket versioning configuration
The following example retrieves bucket versioning configuration.
$result = $client->getBucketRequestPayment([
'Bucket' => 'examplebucket',
]);
Result syntax:
[
'Payer' => 'BucketOwner',
]
GetBucketTagging
$result = $client->getBucketTagging([/* ... */]); $promise = $client->getBucketTaggingAsync([/* ... */]);
Returns the tag set associated with the bucket.
To use this operation, you must have permission to perform the s3:GetBucketTagging action. By default, the bucket owner has this permission and can grant this permission to others.
GetBucketTagging has the following special error:
- Error code:
NoSuchTagSetError- Description: There is no tag set associated with the bucket.
The following operations are related to GetBucketTagging:
Parameter Syntax
$result = $client->getBucketTagging([
'Bucket' => '<string>', // REQUIRED
'ExpectedBucketOwner' => '<string>',
]);
Parameter Details
Members
- Bucket
-
- Required: Yes
- Type: string
The name of the bucket for which to get the tagging information.
- ExpectedBucketOwner
-
- Type: string
The account ID of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP
403 (Access Denied)error.
Result Syntax
[
'TagSet' => [
[
'Key' => '<string>',
'Value' => '<string>',
],
// ...
],
]
Result Details
Members
- TagSet
-
- Required: Yes
- Type: Array of Tag structures
Contains the tag set.
Errors
There are no errors described for this operation.
Examples
Example 1: To get tag set associated with a bucket
The following example returns tag set associated with a bucket
$result = $client->getBucketTagging([
'Bucket' => 'examplebucket',
]);
Result syntax:
[
'TagSet' => [
[
'Key' => 'key1',
'Value' => 'value1',
],
[
'Key' => 'key2',
'Value' => 'value2',
],
],
]
GetBucketVersioning
$result = $client->getBucketVersioning([/* ... */]); $promise = $client->getBucketVersioningAsync([/* ... */]);
Returns the versioning state of a bucket.
To retrieve the versioning state of a bucket, you must be the bucket owner.
This implementation also returns the MFA Delete status of the versioning state. If the MFA Delete status is enabled, the bucket owner must use an authentication device to change the versioning state of the bucket.
The following operations are related to GetBucketVersioning:
Parameter Syntax
$result = $client->getBucketVersioning([
'Bucket' => '<string>', // REQUIRED
'ExpectedBucketOwner' => '<string>',
]);
Parameter Details
Members
- Bucket
-
- Required: Yes
- Type: string
The name of the bucket for which to get the versioning information.
- ExpectedBucketOwner
-
- Type: string
The account ID of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP
403 (Access Denied)error.
Result Syntax
[
'MFADelete' => 'Enabled|Disabled',
'Status' => 'Enabled|Suspended',
]
Result Details
Members
- MFADelete
-
- Type: string
Specifies whether MFA delete is enabled in the bucket versioning configuration. This element is only returned if the bucket has been configured with MFA delete. If the bucket has never been so configured, this element is not returned.
- Status
-
- Type: string
The versioning state of the bucket.
Errors
There are no errors described for this operation.
Examples
Example 1: To get bucket versioning configuration
The following example retrieves bucket versioning configuration.
$result = $client->getBucketVersioning([
'Bucket' => 'examplebucket',
]);
Result syntax:
[
'MFADelete' => 'Disabled',
'Status' => 'Enabled',
]
GetBucketWebsite
$result = $client->getBucketWebsite([/* ... */]); $promise = $client->getBucketWebsiteAsync([/* ... */]);
Returns the website configuration for a bucket. To host website on Amazon S3, you can configure a bucket as website by adding a website configuration. For more information about hosting websites, see Hosting Websites on Amazon S3.
This GET action 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.
The following operations are related to DeleteBucketWebsite:
Parameter Syntax
$result = $client->getBucketWebsite([
'Bucket' => '<string>', // REQUIRED
'ExpectedBucketOwner' => '<string>',
]);
Parameter Details
Members
- Bucket
-
- Required: Yes
- Type: string
The bucket name for which to get the website configuration.
- ExpectedBucketOwner
-
- Type: string
The account ID of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP
403 (Access Denied)error.
Result Syntax
[
'ErrorDocument' => [
'Key' => '<string>',
],
'IndexDocument' => [
'Suffix' => '<string>',
],
'RedirectAllRequestsTo' => [
'HostName' => '<string>',
'Protocol' => 'http|https',
],
'RoutingRules' => [
[
'Condition' => [
'HttpErrorCodeReturnedEquals' => '<string>',
'KeyPrefixEquals' => '<string>',
],
'Redirect' => [
'HostName' => '<string>',
'HttpRedirectCode' => '<string>',
'Protocol' => 'http|https',
'ReplaceKeyPrefixWith' => '<string>',
'ReplaceKeyWith' => '<string>',
],
],
// ...
],
]
Result Details
Members
- ErrorDocument
-
- Type: ErrorDocument structure
The object key name of the website error document to use for 4XX class errors.
- IndexDocument
-
- Type: IndexDocument structure
The name of the index document for the website (for example
index.html). - RedirectAllRequestsTo
-
- Type: RedirectAllRequestsTo structure
Specifies the redirect behavior of all requests to a website endpoint of an Amazon S3 bucket.
- RoutingRules
-
- Type: Array of RoutingRule structures
Rules that define when a redirect is applied and the redirect behavior.
Errors
There are no errors described for this operation.
Examples
Example 1: To get bucket website configuration
The following example retrieves website configuration of a bucket.
$result = $client->getBucketWebsite([
'Bucket' => 'examplebucket',
]);
Result syntax:
[
'ErrorDocument' => [
'Key' => 'error.html',
],
'IndexDocument' => [
'Suffix' => 'index.html',
],
]
GetObject
$result = $client->getObject([/* ... */]); $promise = $client->getObjectAsync([/* ... */]);
Retrieves objects from Amazon S3. To use GET, you must have READ access to the object. If you grant READ access to the anonymous user, you can return the object without using an authorization header.
An Amazon S3 bucket has no directory hierarchy such as you would find in a typical computer file system. You can, however, create a logical hierarchy by using object key names that imply a folder structure. For example, instead of naming an object sample.jpg, you can name it photos/2006/February/sample.jpg.
To get an object from such a logical hierarchy, specify the full key name for the object in the GET operation. For a virtual hosted-style request example, if you have the object photos/2006/February/sample.jpg, specify the resource as /photos/2006/February/sample.jpg. For a path-style request example, if you have the object photos/2006/February/sample.jpg in the bucket named examplebucket, specify the resource as /examplebucket/photos/2006/February/sample.jpg. For more information about request types, see HTTP Host Header Bucket Specification.
To distribute large files to many people, you can save bandwidth costs by using BitTorrent. For more information, see Amazon S3 Torrent. For more information about returning the ACL of an object, see GetObjectAcl.
If the object you are retrieving is stored in the S3 Glacier or S3 Glacier Deep Archive storage class, or S3 Intelligent-Tiering Archive or S3 Intelligent-Tiering Deep Archive tiers, before you can retrieve the object you must first restore a copy using RestoreObject. Otherwise, this action returns an InvalidObjectStateError 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:ListBucketpermission on the bucket, Amazon S3 will return an HTTP status code 404 (“no such key”) error. - If you don’t have the
s3:ListBucketpermission, 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 thes3:GetObjectVersionpermission to access a specific version of an object. If you request a specific version, you do not need to have thes3:GetObjectpermission. - 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: truein 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-typeresponse-content-languageresponse-expiresresponse-cache-controlresponse-content-dispositionresponse-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:
Parameter Syntax
$result = $client->getObject([
'Bucket' => '<string>', // REQUIRED
'ExpectedBucketOwner' => '<string>',
'IfMatch' => '<string>',
'IfModifiedSince' => <integer || string || DateTime>,
'IfNoneMatch' => '<string>',
'IfUnmodifiedSince' => <integer || string || DateTime>,
'Key' => '<string>', // REQUIRED
'PartNumber' => <integer>,
'Range' => '<string>',
'RequestPayer' => 'requester',
'ResponseCacheControl' => '<string>',
'ResponseContentDisposition' => '<string>',
'ResponseContentEncoding' => '<string>',
'ResponseContentLanguage' => '<string>',
'ResponseContentType' => '<string>',
'ResponseExpires' => <integer || string || DateTime>,
'SSECustomerAlgorithm' => '<string>',
'SSECustomerKey' => '<string>',
'SSECustomerKeyMD5' => '<string>',
'SaveAs' => '<string>',
'VersionId' => '<string>',
]);
Parameter Details
Members
- Bucket
-
- Required: Yes
- Type: string
The bucket name containing the object.
When using this action with an access point, you must direct requests to the access point hostname. The access point hostname takes the form AccessPointName–AccountId.s3-accesspoint.Region.amazonaws.com. When using this action with an access point through the Amazon Web Services SDKs, you provide the access point ARN in place of the bucket name. For more information about access point ARNs, see Using access points in the Amazon S3 User Guide.
When using an Object Lambda access point the hostname takes the form AccessPointName–AccountId.s3-object-lambda.Region.amazonaws.com.
When using this action with Amazon S3 on Outposts, you must direct requests to the S3 on Outposts hostname. The S3 on Outposts hostname takes the form AccessPointName–AccountId.outpostID.s3-outposts.Region.amazonaws.com. When using this action using S3 on Outposts through the Amazon Web Services SDKs, you provide the Outposts bucket ARN in place of the bucket name. For more information about S3 on Outposts ARNs, see Using S3 on Outposts in the Amazon S3 User Guide.
- ExpectedBucketOwner
-
- Type: string
The account ID of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP
403 (Access Denied)error. - IfMatch
-
- Type: string
Return the object only if its entity tag (ETag) is the same as the one specified, otherwise return a 412 (precondition failed).
- IfModifiedSince
-
- Type: timestamp (string|DateTime or anything parsable by strtotime)
Return the object only if it has been modified since the specified time, otherwise return a 304 (not modified).
- IfNoneMatch
-
- Type: string
Return the object only if its entity tag (ETag) is different from the one specified, otherwise return a 304 (not modified).
- IfUnmodifiedSince
-
- Type: timestamp (string|DateTime or anything parsable by strtotime)
Return the object only if it has not been modified since the specified time, otherwise return a 412 (precondition failed).
- Key
-
- Required: Yes
- Type: string
Key of the object to get.
- PartNumber
-
- Type: int
Part number of the object being read. This is a positive integer between 1 and 10,000. Effectively performs a ‘ranged’ GET request for the part specified. Useful for downloading just a part of an object.
- Range
-
- Type: string
Downloads the specified range bytes of an object. For more information about the HTTP Range header, see https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.35.
Amazon S3 doesn’t support retrieving multiple ranges of data per
GETrequest. - RequestPayer
-
- Type: string
Confirms that the requester knows that they will be charged for the request. Bucket owners need not specify this parameter in their requests. For information about downloading objects from requester pays buckets, see Downloading Objects in Requestor Pays Buckets in the Amazon S3 User Guide.
- ResponseCacheControl
-
- Type: string
Sets the
Cache-Controlheader of the response. - ResponseContentDisposition
-
- Type: string
Sets the
Content-Dispositionheader of the response - ResponseContentEncoding
-
- Type: string
Sets the
Content-Encodingheader of the response. - ResponseContentLanguage
-
- Type: string
Sets the
Content-Languageheader of the response. - ResponseContentType
-
- Type: string
Sets the
Content-Typeheader of the response. - ResponseExpires
-
- Type: timestamp (string|DateTime or anything parsable by strtotime)
Sets the
Expiresheader of the response. - SSECustomerAlgorithm
-
- Type: string
Specifies the algorithm to use to when decrypting the object (for example, AES256).
- SSECustomerKey
-
- Type: string
Specifies the customer-provided encryption key for Amazon S3 used to encrypt the data. This value is used to decrypt the object when recovering it and must match the one used when storing the data. The key must be appropriate for use with the algorithm specified in the
x-amz-server-side-encryption-customer-algorithmheader.This value will be base64 encoded on your behalf. - SSECustomerKeyMD5
-
- Type: string
Specifies the 128-bit MD5 digest of the encryption key according to RFC 1321. Amazon S3 uses this header for a message integrity check to ensure that the encryption key was transmitted without error.
- SaveAs
-
- Type: string
The path to a file on disk to save the object data. - VersionId
-
- Type: string
VersionId used to reference a specific version of the object.
Result Syntax
[
'AcceptRanges' => '<string>',
'Body' => <string || resource || Psr\Http\Message\StreamInterface>,
'BucketKeyEnabled' => true || false,
'CacheControl' => '<string>',
'ContentDisposition' => '<string>',
'ContentEncoding' => '<string>',
'ContentLanguage' => '<string>',
'ContentLength' => <integer>,
'ContentRange' => '<string>',
'ContentType' => '<string>',
'DeleteMarker' => true || false,
'ETag' => '<string>',
'Expiration' => '<string>',
'Expires' => <DateTime>,
'LastModified' => <DateTime>,
'Metadata' => ['<string>', ...],
'MissingMeta' => <integer>,
'ObjectLockLegalHoldStatus' => 'ON|OFF',
'ObjectLockMode' => 'GOVERNANCE|COMPLIANCE',
'ObjectLockRetainUntilDate' => <DateTime>,
'PartsCount' => <integer>,
'ReplicationStatus' => 'COMPLETE|PENDING|FAILED|REPLICA',
'RequestCharged' => 'requester',
'Restore' => '<string>',
'SSECustomerAlgorithm' => '<string>',
'SSECustomerKeyMD5' => '<string>',
'SSEKMSKeyId' => '<string>',
'ServerSideEncryption' => 'AES256|aws:kms',
'StorageClass' => 'STANDARD|REDUCED_REDUNDANCY|STANDARD_IA|ONEZONE_IA|INTELLIGENT_TIERING|GLACIER|DEEP_ARCHIVE|OUTPOSTS|GLACIER_IR',
'TagCount' => <integer>,
'VersionId' => '<string>',
'WebsiteRedirectLocation' => '<string>',
]
Result Details
Members
- AcceptRanges
-
- Type: string
Indicates that a range of bytes was specified.
- Body
-
- Type: blob (string|resource|Psr\Http\Message\StreamInterface)
Object data.
- BucketKeyEnabled
-
- Type: boolean
Indicates whether the object uses an S3 Bucket Key for server-side encryption with Amazon Web Services KMS (SSE-KMS).
- CacheControl
-
- Type: string
Specifies caching behavior along the request/reply chain.
- ContentDisposition
-
- Type: string
Specifies presentational information for the object.
- ContentEncoding
-
- Type: string
Specifies what content encodings have been applied to the object and thus what decoding mechanisms must be applied to obtain the media-type referenced by the Content-Type header field.
- ContentLanguage
-
- Type: string
The language the content is in.
- ContentLength
-
- Type: long (int|float)
Size of the body in bytes.
- ContentRange
-
- Type: string
The portion of the object returned in the response.
- ContentType
-
- Type: string
A standard MIME type describing the format of the object data.
- DeleteMarker
-
- Type: boolean
Specifies whether the object retrieved was (true) or was not (false) a Delete Marker. If false, this response header does not appear in the response.
- ETag
-
- Type: string
An ETag is an opaque identifier assigned by a web server to a specific version of a resource found at a URL.
- Expiration
-
- Type: string
If the object expiration is configured (see PUT Bucket lifecycle), the response includes this header. It includes the expiry-date and rule-id key-value pairs providing object expiration information. The value of the rule-id is URL encoded.
- Expires
-
- Type: timestamp (string|DateTime or anything parsable by strtotime)
The date and time at which the object is no longer cacheable.
- LastModified
-
- Type: timestamp (string|DateTime or anything parsable by strtotime)
Creation date of the object.
- Metadata
-
- Type: Associative array of custom strings keys (MetadataKey) to strings
A map of metadata to store with the object in S3.