Table of Contents
A low-level client representing Amazon Simple Storage Service (S3):
import boto3
client = boto3.client('s3')
These are the available methods:
Aborts a multipart upload.
To verify that all parts have been removed, so you don't get charged for the part storage, you should call the List Parts operation and ensure the parts list is empty.
See also: AWS API Documentation
Request Syntax
response = client.abort_multipart_upload(
Bucket='string',
Key='string',
UploadId='string',
RequestPayer='requester'
)
dict
Response Syntax
{
'RequestCharged': 'requester'
}
Response Structure
Check if an operation can be paginated.
Completes a multipart upload by assembling previously uploaded parts.
See also: AWS API Documentation
Request Syntax
response = client.complete_multipart_upload(
Bucket='string',
Key='string',
MultipartUpload={
'Parts': [
{
'ETag': 'string',
'PartNumber': 123
},
]
},
UploadId='string',
RequestPayer='requester'
)
dict
Response Syntax
{
'Location': 'string',
'Bucket': 'string',
'Key': 'string',
'Expiration': 'string',
'ETag': 'string',
'ServerSideEncryption': 'AES256'|'aws:kms',
'VersionId': 'string',
'SSEKMSKeyId': 'string',
'RequestCharged': 'requester'
}
Response Structure
Copy an object from one S3 location to another.
This is a managed transfer which will perform a multipart copy in multiple threads if necessary.
Usage:
import boto3
s3 = boto3.resource('s3')
copy_source = {
'Bucket': 'mybucket',
'Key': 'mykey'
}
s3.meta.client.copy(copy_source, 'otherbucket', 'otherkey')
Creates a copy of an object that is already stored in Amazon S3.
See also: AWS API Documentation
Request Syntax
response = client.copy_object(
ACL='private'|'public-read'|'public-read-write'|'authenticated-read'|'aws-exec-read'|'bucket-owner-read'|'bucket-owner-full-control',
Bucket='string',
CacheControl='string',
ContentDisposition='string',
ContentEncoding='string',
ContentLanguage='string',
ContentType='string',
CopySource='string' or {'Bucket': 'string', 'Key': 'string', 'VersionId': 'string'},
CopySourceIfMatch='string',
CopySourceIfModifiedSince=datetime(2015, 1, 1),
CopySourceIfNoneMatch='string',
CopySourceIfUnmodifiedSince=datetime(2015, 1, 1),
Expires=datetime(2015, 1, 1),
GrantFullControl='string',
GrantRead='string',
GrantReadACP='string',
GrantWriteACP='string',
Key='string',
Metadata={
'string': 'string'
},
MetadataDirective='COPY'|'REPLACE',
TaggingDirective='COPY'|'REPLACE',
ServerSideEncryption='AES256'|'aws:kms',
StorageClass='STANDARD'|'REDUCED_REDUNDANCY'|'STANDARD_IA',
WebsiteRedirectLocation='string',
SSECustomerAlgorithm='string',
SSECustomerKey='string',
SSEKMSKeyId='string',
CopySourceSSECustomerAlgorithm='string',
CopySourceSSECustomerKey='string',
RequestPayer='requester',
Tagging='string'
)
A map of metadata to store with the object in S3.
dict
Response Syntax
{
'CopyObjectResult': {
'ETag': 'string',
'LastModified': datetime(2015, 1, 1)
},
'Expiration': 'string',
'CopySourceVersionId': 'string',
'VersionId': 'string',
'ServerSideEncryption': 'AES256'|'aws:kms',
'SSECustomerAlgorithm': 'string',
'SSECustomerKeyMD5': 'string',
'SSEKMSKeyId': 'string',
'RequestCharged': 'requester'
}
Response Structure
Creates a new bucket.
See also: AWS API Documentation
Request Syntax
response = client.create_bucket(
ACL='private'|'public-read'|'public-read-write'|'authenticated-read',
Bucket='string',
CreateBucketConfiguration={
'LocationConstraint': 'EU'|'eu-west-1'|'us-west-1'|'us-west-2'|'ap-south-1'|'ap-southeast-1'|'ap-southeast-2'|'ap-northeast-1'|'sa-east-1'|'cn-north-1'|'eu-central-1'
},
GrantFullControl='string',
GrantRead='string',
GrantReadACP='string',
GrantWrite='string',
GrantWriteACP='string'
)
dict
Response Syntax
{
'Location': 'string'
}
Response Structure
Initiates a multipart upload and returns an upload ID.
Note: After you initiate multipart upload and upload one or more parts, you must either complete or abort multipart upload in order to stop getting charged for storage of the uploaded parts. Only after you either complete or abort multipart upload, Amazon S3 frees up the parts storage and stops charging you for the parts storage.
See also: AWS API Documentation
Request Syntax
response = client.create_multipart_upload(
ACL='private'|'public-read'|'public-read-write'|'authenticated-read'|'aws-exec-read'|'bucket-owner-read'|'bucket-owner-full-control',
Bucket='string',
CacheControl='string',
ContentDisposition='string',
ContentEncoding='string',
ContentLanguage='string',
ContentType='string',
Expires=datetime(2015, 1, 1),
GrantFullControl='string',
GrantRead='string',
GrantReadACP='string',
GrantWriteACP='string',
Key='string',
Metadata={
'string': 'string'
},
ServerSideEncryption='AES256'|'aws:kms',
StorageClass='STANDARD'|'REDUCED_REDUNDANCY'|'STANDARD_IA',
WebsiteRedirectLocation='string',
SSECustomerAlgorithm='string',
SSECustomerKey='string',
SSEKMSKeyId='string',
RequestPayer='requester'
)
A map of metadata to store with the object in S3.
dict
Response Syntax
{
'AbortDate': datetime(2015, 1, 1),
'AbortRuleId': 'string',
'Bucket': 'string',
'Key': 'string',
'UploadId': 'string',
'ServerSideEncryption': 'AES256'|'aws:kms',
'SSECustomerAlgorithm': 'string',
'SSECustomerKeyMD5': 'string',
'SSEKMSKeyId': 'string',
'RequestCharged': 'requester'
}
Response Structure
Deletes the bucket. All objects (including all object versions and Delete Markers) in the bucket must be deleted before the bucket itself can be deleted.
See also: AWS API Documentation
Request Syntax
response = client.delete_bucket(
Bucket='string'
)
Deletes an analytics configuration for the bucket (specified by the analytics configuration ID).
See also: AWS API Documentation
Request Syntax
response = client.delete_bucket_analytics_configuration(
Bucket='string',
Id='string'
)
None
Deletes the cors configuration information set for the bucket.
See also: AWS API Documentation
Request Syntax
response = client.delete_bucket_cors(
Bucket='string'
)
Deletes an inventory configuration (identified by the inventory ID) from the bucket.
See also: AWS API Documentation
Request Syntax
response = client.delete_bucket_inventory_configuration(
Bucket='string',
Id='string'
)
None
Deletes the lifecycle configuration from the bucket.
See also: AWS API Documentation
Request Syntax
response = client.delete_bucket_lifecycle(
Bucket='string'
)
Deletes a metrics configuration (specified by the metrics configuration ID) from the bucket.
See also: AWS API Documentation
Request Syntax
response = client.delete_bucket_metrics_configuration(
Bucket='string',
Id='string'
)
None
Deletes the policy from the bucket.
See also: AWS API Documentation
Request Syntax
response = client.delete_bucket_policy(
Bucket='string'
)
Deletes the replication configuration from the bucket.
See also: AWS API Documentation
Request Syntax
response = client.delete_bucket_replication(
Bucket='string'
)
Deletes the tags from the bucket.
See also: AWS API Documentation
Request Syntax
response = client.delete_bucket_tagging(
Bucket='string'
)
This operation removes the website configuration from the bucket.
See also: AWS API Documentation
Request Syntax
response = client.delete_bucket_website(
Bucket='string'
)
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.
See also: AWS API Documentation
Request Syntax
response = client.delete_object(
Bucket='string',
Key='string',
MFA='string',
VersionId='string',
RequestPayer='requester'
)
dict
Response Syntax
{
'DeleteMarker': True|False,
'VersionId': 'string',
'RequestCharged': 'requester'
}
Response Structure
Removes the tag-set from an existing object.
See also: AWS API Documentation
Request Syntax
response = client.delete_object_tagging(
Bucket='string',
Key='string',
VersionId='string'
)
dict
Response Syntax
{
'VersionId': 'string'
}
Response Structure
This operation enables you to delete multiple objects from a bucket using a single HTTP request. You may specify up to 1000 keys.
See also: AWS API Documentation
Request Syntax
response = client.delete_objects(
Bucket='string',
Delete={
'Objects': [
{
'Key': 'string',
'VersionId': 'string'
},
],
'Quiet': True|False
},
MFA='string',
RequestPayer='requester'
)
[REQUIRED]
dict
Response Syntax
{
'Deleted': [
{
'Key': 'string',
'VersionId': 'string',
'DeleteMarker': True|False,
'DeleteMarkerVersionId': 'string'
},
],
'RequestCharged': 'requester',
'Errors': [
{
'Key': 'string',
'VersionId': 'string',
'Code': 'string',
'Message': 'string'
},
]
}
Response Structure
Download an S3 object to a file.
Usage:
import boto3
s3 = boto3.resource('s3')
s3.meta.client.download_file('mybucket', 'hello.txt', '/tmp/hello.txt')
Similar behavior as S3Transfer's download_file() method, except that parameters are capitalized. Detailed examples can be found at S3Transfer's Usage.
Download an object from S3 to a file-like object.
The file-like object must be in binary mode.
This is a managed transfer which will perform a multipart download in multiple threads if necessary.
Usage:
import boto3
s3 = boto3.client('s3')
with open('filename', 'wb') as data:
s3.download_fileobj('mybucket', 'mykey', data)
Builds the url and the form fields used for a presigned s3 post
A dictionary of prefilled form fields to build on top of. Elements that may be included are acl, Cache-Control, Content-Type, Content-Disposition, Content-Encoding, Expires, success_action_redirect, redirect, success_action_status, and x-amz-meta-.
Note that if a particular element is included in the fields dictionary it will not be automatically added to the conditions list. You must specify a condition for the element as well.
A list of conditions to include in the policy. Each element can be either a list or a structure. For example:
]
Conditions that are included may pertain to acl, content-length-range, Cache-Control, Content-Type, Content-Disposition, Content-Encoding, Expires, success_action_redirect, redirect, success_action_status, and/or x-amz-meta-.
Note that if you include a condition, you must specify the a valid value in the fields dictionary as well. A value will not be added automatically to the fields dictionary based on the conditions.
dict
A dictionary with two elements: url and fields. Url is the url to post to. Fields is a dictionary filled with the form fields and respective values to use when submitting the post. For example:
'key': 'mykey', 'signature': 'mysignature', 'policy': 'mybase64 encoded policy'}
}
Generate a presigned url given a client, its method, and arguments
The presigned url
Returns the accelerate configuration of a bucket.
See also: AWS API Documentation
Request Syntax
response = client.get_bucket_accelerate_configuration(
Bucket='string'
)
{
'Status': 'Enabled'|'Suspended'
}
Response Structure
Gets the access control policy for the bucket.
See also: AWS API Documentation
Request Syntax
response = client.get_bucket_acl(
Bucket='string'
)
{
'Owner': {
'DisplayName': 'string',
'ID': 'string'
},
'Grants': [
{
'Grantee': {
'DisplayName': 'string',
'EmailAddress': 'string',
'ID': 'string',
'Type': 'CanonicalUser'|'AmazonCustomerByEmail'|'Group',
'URI': 'string'
},
'Permission': 'FULL_CONTROL'|'WRITE'|'WRITE_ACP'|'READ'|'READ_ACP'
},
]
}
Response Structure
Gets an analytics configuration for the bucket (specified by the analytics configuration ID).
See also: AWS API Documentation
Request Syntax
response = client.get_bucket_analytics_configuration(
Bucket='string',
Id='string'
)
dict
Response Syntax
{
'AnalyticsConfiguration': {
'Id': 'string',
'Filter': {
'Prefix': 'string',
'Tag': {
'Key': 'string',
'Value': 'string'
},
'And': {
'Prefix': 'string',
'Tags': [
{
'Key': 'string',
'Value': 'string'
},
]
}
},
'StorageClassAnalysis': {
'DataExport': {
'OutputSchemaVersion': 'V_1',
'Destination': {
'S3BucketDestination': {
'Format': 'CSV',
'BucketAccountId': 'string',
'Bucket': 'string',
'Prefix': 'string'
}
}
}
}
}
}
Response Structure
Returns the cors configuration for the bucket.
See also: AWS API Documentation
Request Syntax
response = client.get_bucket_cors(
Bucket='string'
)
{
'CORSRules': [
{
'AllowedHeaders': [
'string',
],
'AllowedMethods': [
'string',
],
'AllowedOrigins': [
'string',
],
'ExposeHeaders': [
'string',
],
'MaxAgeSeconds': 123
},
]
}
Response Structure
Returns an inventory configuration (identified by the inventory ID) from the bucket.
See also: AWS API Documentation
Request Syntax
response = client.get_bucket_inventory_configuration(
Bucket='string',
Id='string'
)
dict
Response Syntax
{
'InventoryConfiguration': {
'Destination': {
'S3BucketDestination': {
'AccountId': 'string',
'Bucket': 'string',
'Format': 'CSV',
'Prefix': 'string'
}
},
'IsEnabled': True|False,
'Filter': {
'Prefix': 'string'
},
'Id': 'string',
'IncludedObjectVersions': 'All'|'Current',
'OptionalFields': [
'Size'|'LastModifiedDate'|'StorageClass'|'ETag'|'IsMultipartUploaded'|'ReplicationStatus',
],
'Schedule': {
'Frequency': 'Daily'|'Weekly'
}
}
}
Response Structure
Deprecated, see the GetBucketLifecycleConfiguration operation.
See also: AWS API Documentation
Request Syntax
response = client.get_bucket_lifecycle(
Bucket='string'
)
{
'Rules': [
{
'Expiration': {
'Date': datetime(2015, 1, 1),
'Days': 123,
'ExpiredObjectDeleteMarker': True|False
},
'ID': 'string',
'Prefix': 'string',
'Status': 'Enabled'|'Disabled',
'Transition': {
'Date': datetime(2015, 1, 1),
'Days': 123,
'StorageClass': 'GLACIER'|'STANDARD_IA'
},
'NoncurrentVersionTransition': {
'NoncurrentDays': 123,
'StorageClass': 'GLACIER'|'STANDARD_IA'
},
'NoncurrentVersionExpiration': {
'NoncurrentDays': 123
},
'AbortIncompleteMultipartUpload': {
'DaysAfterInitiation': 123
}
},
]
}
Response Structure
Returns the lifecycle configuration information set on the bucket.
See also: AWS API Documentation
Request Syntax
response = client.get_bucket_lifecycle_configuration(
Bucket='string'
)
{
'Rules': [
{
'Expiration': {
'Date': datetime(2015, 1, 1),
'Days': 123,
'ExpiredObjectDeleteMarker': True|False
},
'ID': 'string',
'Prefix': 'string',
'Filter': {
'Prefix': 'string',
'Tag': {
'Key': 'string',
'Value': 'string'
},
'And': {
'Prefix': 'string',
'Tags': [
{
'Key': 'string',
'Value': 'string'
},
]
}
},
'Status': 'Enabled'|'Disabled',
'Transitions': [
{
'Date': datetime(2015, 1, 1),
'Days': 123,
'StorageClass': 'GLACIER'|'STANDARD_IA'
},
],
'NoncurrentVersionTransitions': [
{
'NoncurrentDays': 123,
'StorageClass': 'GLACIER'|'STANDARD_IA'
},
],
'NoncurrentVersionExpiration': {
'NoncurrentDays': 123
},
'AbortIncompleteMultipartUpload': {
'DaysAfterInitiation': 123
}
},
]
}
Response Structure
Returns the region the bucket resides in.
See also: AWS API Documentation
Request Syntax
response = client.get_bucket_location(
Bucket='string'
)
{
'LocationConstraint': 'EU'|'eu-west-1'|'us-west-1'|'us-west-2'|'ap-south-1'|'ap-southeast-1'|'ap-southeast-2'|'ap-northeast-1'|'sa-east-1'|'cn-north-1'|'eu-central-1'
}
Response Structure
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.
See also: AWS API Documentation
Request Syntax
response = client.get_bucket_logging(
Bucket='string'
)
{
'LoggingEnabled': {
'TargetBucket': 'string',
'TargetGrants': [
{
'Grantee': {
'DisplayName': 'string',
'EmailAddress': 'string',
'ID': 'string',
'Type': 'CanonicalUser'|'AmazonCustomerByEmail'|'Group',
'URI': 'string'
},
'Permission': 'FULL_CONTROL'|'READ'|'WRITE'
},
],
'TargetPrefix': 'string'
}
}
Response Structure
Gets a metrics configuration (specified by the metrics configuration ID) from the bucket.
See also: AWS API Documentation
Request Syntax
response = client.get_bucket_metrics_configuration(
Bucket='string',
Id='string'
)
dict
Response Syntax
{
'MetricsConfiguration': {
'Id': 'string',
'Filter': {
'Prefix': 'string',
'Tag': {
'Key': 'string',
'Value': 'string'
},
'And': {
'Prefix': 'string',
'Tags': [
{
'Key': 'string',
'Value': 'string'
},
]
}
}
}
}
Response Structure
Deprecated, see the GetBucketNotificationConfiguration operation.
See also: AWS API Documentation
Request Syntax
response = client.get_bucket_notification(
Bucket='string'
)
{
'TopicConfiguration': {
'Id': 'string',
'Events': [
's3:ReducedRedundancyLostObject'|'s3:ObjectCreated:*'|'s3:ObjectCreated:Put'|'s3:ObjectCreated:Post'|'s3:ObjectCreated:Copy'|'s3:ObjectCreated:CompleteMultipartUpload'|'s3:ObjectRemoved:*'|'s3:ObjectRemoved:Delete'|'s3:ObjectRemoved:DeleteMarkerCreated',
],
'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',
'Topic': 'string'
},
'QueueConfiguration': {
'Id': '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',
'Events': [
's3:ReducedRedundancyLostObject'|'s3:ObjectCreated:*'|'s3:ObjectCreated:Put'|'s3:ObjectCreated:Post'|'s3:ObjectCreated:Copy'|'s3:ObjectCreated:CompleteMultipartUpload'|'s3:ObjectRemoved:*'|'s3:ObjectRemoved:Delete'|'s3:ObjectRemoved:DeleteMarkerCreated',
],
'Queue': 'string'
},
'CloudFunctionConfiguration': {
'Id': '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',
'Events': [
's3:ReducedRedundancyLostObject'|'s3:ObjectCreated:*'|'s3:ObjectCreated:Put'|'s3:ObjectCreated:Post'|'s3:ObjectCreated:Copy'|'s3:ObjectCreated:CompleteMultipartUpload'|'s3:ObjectRemoved:*'|'s3:ObjectRemoved:Delete'|'s3:ObjectRemoved:DeleteMarkerCreated',
],
'CloudFunction': 'string',
'InvocationRole': 'string'
}
}
Response Structure
Returns the notification configuration of a bucket.
See also: AWS API Documentation
Request Syntax
response = client.get_bucket_notification_configuration(
Bucket='string'
)
{
'TopicConfigurations': [
{
'Id': 'string',
'TopicArn': 'string',
'Events': [
's3:ReducedRedundancyLostObject'|'s3:ObjectCreated:*'|'s3:ObjectCreated:Put'|'s3:ObjectCreated:Post'|'s3:ObjectCreated:Copy'|'s3:ObjectCreated:CompleteMultipartUpload'|'s3:ObjectRemoved:*'|'s3:ObjectRemoved:Delete'|'s3:ObjectRemoved:DeleteMarkerCreated',
],
'Filter': {
'Key': {
'FilterRules': [
{
'Name': 'prefix'|'suffix',
'Value': 'string'
},
]
}
}
},
],
'QueueConfigurations': [
{
'Id': 'string',
'QueueArn': 'string',
'Events': [
's3:ReducedRedundancyLostObject'|'s3:ObjectCreated:*'|'s3:ObjectCreated:Put'|'s3:ObjectCreated:Post'|'s3:ObjectCreated:Copy'|'s3:ObjectCreated:CompleteMultipartUpload'|'s3:ObjectRemoved:*'|'s3:ObjectRemoved:Delete'|'s3:ObjectRemoved:DeleteMarkerCreated',
],
'Filter': {
'Key': {
'FilterRules': [
{
'Name': 'prefix'|'suffix',
'Value': 'string'
},
]
}
}
},
],
'LambdaFunctionConfigurations': [
{
'Id': 'string',
'LambdaFunctionArn': 'string',
'Events': [
's3:ReducedRedundancyLostObject'|'s3:ObjectCreated:*'|'s3:ObjectCreated:Put'|'s3:ObjectCreated:Post'|'s3:ObjectCreated:Copy'|'s3:ObjectCreated:CompleteMultipartUpload'|'s3:ObjectRemoved:*'|'s3:ObjectRemoved:Delete'|'s3:ObjectRemoved:DeleteMarkerCreated',
],
'Filter': {
'Key': {
'FilterRules': [
{
'Name': 'prefix'|'suffix',
'Value': 'string'
},
]
}
}
},
]
}
Response Structure
Returns the policy of a specified bucket.
See also: AWS API Documentation
Request Syntax
response = client.get_bucket_policy(
Bucket='string'
)
{
'Policy': 'string'
}
Response Structure
Returns the replication configuration of a bucket.
See also: AWS API Documentation
Request Syntax
response = client.get_bucket_replication(
Bucket='string'
)
{
'ReplicationConfiguration': {
'Role': 'string',
'Rules': [
{
'ID': 'string',
'Prefix': 'string',
'Status': 'Enabled'|'Disabled',
'Destination': {
'Bucket': 'string',
'StorageClass': 'STANDARD'|'REDUCED_REDUNDANCY'|'STANDARD_IA'
}
},
]
}
}
Response Structure
Returns the request payment configuration of a bucket.
See also: AWS API Documentation
Request Syntax
response = client.get_bucket_request_payment(
Bucket='string'
)
{
'Payer': 'Requester'|'BucketOwner'
}
Response Structure
Returns the tag set associated with the bucket.
See also: AWS API Documentation
Request Syntax
response = client.get_bucket_tagging(
Bucket='string'
)
{
'TagSet': [
{
'Key': 'string',
'Value': 'string'
},
]
}
Response Structure
Returns the versioning state of a bucket.
See also: AWS API Documentation
Request Syntax
response = client.get_bucket_versioning(
Bucket='string'
)
{
'Status': 'Enabled'|'Suspended',
'MFADelete': 'Enabled'|'Disabled'
}
Response Structure
Returns the website configuration for a bucket.
See also: AWS API Documentation
Request Syntax
response = client.get_bucket_website(
Bucket='string'
)
{
'RedirectAllRequestsTo': {
'HostName': 'string',
'Protocol': 'http'|'https'
},
'IndexDocument': {
'Suffix': 'string'
},
'ErrorDocument': {
'Key': 'string'
},
'RoutingRules': [
{
'Condition': {
'HttpErrorCodeReturnedEquals': 'string',
'KeyPrefixEquals': 'string'
},
'Redirect': {
'HostName': 'string',
'HttpRedirectCode': 'string',
'Protocol': 'http'|'https',
'ReplaceKeyPrefixWith': 'string',
'ReplaceKeyWith': 'string'
}
},
]
}
Response Structure
Retrieves objects from Amazon S3.
See also: AWS API Documentation
Request Syntax
response = client.get_object(
Bucket='string',
IfMatch='string',
IfModifiedSince=datetime(2015, 1, 1),
IfNoneMatch='string',
IfUnmodifiedSince=datetime(2015, 1, 1),
Key='string',
Range='string',
ResponseCacheControl='string',
ResponseContentDisposition='string',
ResponseContentEncoding='string',
ResponseContentLanguage='string',
ResponseContentType='string',
ResponseExpires=datetime(2015, 1, 1),
VersionId='string',
SSECustomerAlgorithm='string',
SSECustomerKey='string',
RequestPayer='requester',
PartNumber=123
)
dict
Response Syntax
{
'Body': StreamingBody(),
'DeleteMarker': True|False,
'AcceptRanges': 'string',
'Expiration': 'string',
'Restore': 'string',
'LastModified': datetime(2015, 1, 1),
'ContentLength': 123,
'ETag': 'string',
'MissingMeta': 123,
'VersionId': 'string',
'CacheControl': 'string',
'ContentDisposition': 'string',
'ContentEncoding': 'string',
'ContentLanguage': 'string',
'ContentRange': 'string',
'ContentType': 'string',
'Expires': datetime(2015, 1, 1),
'WebsiteRedirectLocation': 'string',
'ServerSideEncryption': 'AES256'|'aws:kms',
'Metadata': {
'string': 'string'
},
'SSECustomerAlgorithm': 'string',
'SSECustomerKeyMD5': 'string',
'SSEKMSKeyId': 'string',
'StorageClass': 'STANDARD'|'REDUCED_REDUNDANCY'|'STANDARD_IA',
'RequestCharged': 'requester',
'ReplicationStatus': 'COMPLETE'|'PENDING'|'FAILED'|'REPLICA',
'PartsCount': 123,
'TagCount': 123
}
Response Structure
Returns the access control list (ACL) of an object.
See also: AWS API Documentation
Request Syntax
response = client.get_object_acl(
Bucket='string',
Key='string',
VersionId='string',
RequestPayer='requester'
)
dict
Response Syntax
{
'Owner': {
'DisplayName': 'string',
'ID': 'string'
},
'Grants': [
{
'Grantee': {
'DisplayName': 'string',
'EmailAddress': 'string',
'ID': 'string',
'Type': 'CanonicalUser'|'AmazonCustomerByEmail'|'Group',
'URI': 'string'
},
'Permission': 'FULL_CONTROL'|'WRITE'|'WRITE_ACP'|'READ'|'READ_ACP'
},
],
'RequestCharged': 'requester'
}
Response Structure
Returns the tag-set of an object.
See also: AWS API Documentation
Request Syntax
response = client.get_object_tagging(
Bucket='string',
Key='string',
VersionId='string'
)
dict
Response Syntax
{
'VersionId': 'string',
'TagSet': [
{
'Key': 'string',
'Value': 'string'
},
]
}
Response Structure
Return torrent files from a bucket.
See also: AWS API Documentation
Request Syntax
response = client.get_object_torrent(
Bucket='string',
Key='string',
RequestPayer='requester'
)
dict
Response Syntax
{
'Body': StreamingBody(),
'RequestCharged': 'requester'
}
Response Structure
Create a paginator for an operation.
This operation is useful to determine if a bucket exists and you have permission to access it.
See also: AWS API Documentation
Request Syntax
response = client.head_bucket(
Bucket='string'
)
The HEAD operation retrieves metadata from an object without returning the object itself. This operation is useful if you're only interested in an object's metadata. To use HEAD, you must have READ access to the object.
See also: AWS API Documentation
Request Syntax
response = client.head_object(
Bucket='string',
IfMatch='string',
IfModifiedSince=datetime(2015, 1, 1),
IfNoneMatch='string',
IfUnmodifiedSince=datetime(2015, 1, 1),
Key='string',
Range='string',
VersionId='string',
SSECustomerAlgorithm='string',
SSECustomerKey='string',
RequestPayer='requester',
PartNumber=123
)
dict
Response Syntax
{
'DeleteMarker': True|False,
'AcceptRanges': 'string',
'Expiration': 'string',
'Restore': 'string',
'LastModified': datetime(2015, 1, 1),
'ContentLength': 123,
'ETag': 'string',
'MissingMeta': 123,
'VersionId': 'string',
'CacheControl': 'string',
'ContentDisposition': 'string',
'ContentEncoding': 'string',
'ContentLanguage': 'string',
'ContentType': 'string',
'Expires': datetime(2015, 1, 1),
'WebsiteRedirectLocation': 'string',
'ServerSideEncryption': 'AES256'|'aws:kms',
'Metadata': {
'string': 'string'
},
'SSECustomerAlgorithm': 'string',
'SSECustomerKeyMD5': 'string',
'SSEKMSKeyId': 'string',
'StorageClass': 'STANDARD'|'REDUCED_REDUNDANCY'|'STANDARD_IA',
'RequestCharged': 'requester',
'ReplicationStatus': 'COMPLETE'|'PENDING'|'FAILED'|'REPLICA',
'PartsCount': 123
}
Response Structure
Lists the analytics configurations for the bucket.
See also: AWS API Documentation
Request Syntax
response = client.list_bucket_analytics_configurations(
Bucket='string',
ContinuationToken='string'
)
dict
Response Syntax
{
'IsTruncated': True|False,
'ContinuationToken': 'string',
'NextContinuationToken': 'string',
'AnalyticsConfigurationList': [
{
'Id': 'string',
'Filter': {
'Prefix': 'string',
'Tag': {
'Key': 'string',
'Value': 'string'
},
'And': {
'Prefix': 'string',
'Tags': [
{
'Key': 'string',
'Value': 'string'
},
]
}
},
'StorageClassAnalysis': {
'DataExport': {
'OutputSchemaVersion': 'V_1',
'Destination': {
'S3BucketDestination': {
'Format': 'CSV',
'BucketAccountId': 'string',
'Bucket': 'string',
'Prefix': 'string'
}
}
}
}
},
]
}
Response Structure
Returns a list of inventory configurations for the bucket.
See also: AWS API Documentation
Request Syntax
response = client.list_bucket_inventory_configurations(
Bucket='string',
ContinuationToken='string'
)
dict
Response Syntax
{
'ContinuationToken': 'string',
'InventoryConfigurationList': [
{
'Destination': {
'S3BucketDestination': {
'AccountId': 'string',
'Bucket': 'string',
'Format': 'CSV',
'Prefix': 'string'
}
},
'IsEnabled': True|False,
'Filter': {
'Prefix': 'string'
},
'Id': 'string',
'IncludedObjectVersions': 'All'|'Current',
'OptionalFields': [
'Size'|'LastModifiedDate'|'StorageClass'|'ETag'|'IsMultipartUploaded'|'ReplicationStatus',
],
'Schedule': {
'Frequency': 'Daily'|'Weekly'
}
},
],
'IsTruncated': True|False,
'NextContinuationToken': 'string'
}
Response Structure
Lists the metrics configurations for the bucket.
See also: AWS API Documentation
Request Syntax
response = client.list_bucket_metrics_configurations(
Bucket='string',
ContinuationToken='string'
)
dict
Response Syntax
{
'IsTruncated': True|False,
'ContinuationToken': 'string',
'NextContinuationToken': 'string',
'MetricsConfigurationList': [
{
'Id': 'string',
'Filter': {
'Prefix': 'string',
'Tag': {
'Key': 'string',
'Value': 'string'
},
'And': {
'Prefix': 'string',
'Tags': [
{
'Key': 'string',
'Value': 'string'
},
]
}
}
},
]
}
Response Structure
Returns a list of all buckets owned by the authenticated sender of the request.
See also: AWS API Documentation
Request Syntax
response = client.list_buckets()
{
'Buckets': [
{
'Name': 'string',
'CreationDate': datetime(2015, 1, 1)
},
],
'Owner': {
'DisplayName': 'string',
'ID': 'string'
}
}
Response Structure
This operation lists in-progress multipart uploads.
See also: AWS API Documentation
Request Syntax
response = client.list_multipart_uploads(
Bucket='string',
Delimiter='string',
EncodingType='url',
KeyMarker='string',
MaxUploads=123,
Prefix='string',
UploadIdMarker='string'
)
dict
Response Syntax
{
'Bucket': 'string',
'KeyMarker': 'string',
'UploadIdMarker': 'string',
'NextKeyMarker': 'string',
'Prefix': 'string',
'Delimiter': 'string',
'NextUploadIdMarker': 'string',
'MaxUploads': 123,
'IsTruncated': True|False,
'Uploads': [
{
'UploadId': 'string',
'Key': 'string',
'Initiated': datetime(2015, 1, 1),
'StorageClass': 'STANDARD'|'REDUCED_REDUNDANCY'|'STANDARD_IA',
'Owner': {
'DisplayName': 'string',
'ID': 'string'
},
'Initiator': {
'ID': 'string',
'DisplayName': 'string'
}
},
],
'CommonPrefixes': [
{
'Prefix': 'string'
},
],
'EncodingType': 'url'
}
Response Structure
Returns metadata about all of the versions of objects in a bucket.
See also: AWS API Documentation
Request Syntax
response = client.list_object_versions(
Bucket='string',
Delimiter='string',
EncodingType='url',
KeyMarker='string',
MaxKeys=123,
Prefix='string',
VersionIdMarker='string'
)
dict
Response Syntax
{
'IsTruncated': True|False,
'KeyMarker': 'string',
'VersionIdMarker': 'string',
'NextKeyMarker': 'string',
'NextVersionIdMarker': 'string',
'Versions': [
{
'ETag': 'string',
'Size': 123,
'StorageClass': 'STANDARD',
'Key': 'string',
'VersionId': 'string',
'IsLatest': True|False,
'LastModified': datetime(2015, 1, 1),
'Owner': {
'DisplayName': 'string',
'ID': 'string'
}
},
],
'DeleteMarkers': [
{
'Owner': {
'DisplayName': 'string',
'ID': 'string'
},
'Key': 'string',
'VersionId': 'string',
'IsLatest': True|False,
'LastModified': datetime(2015, 1, 1)
},
],
'Name': 'string',
'Prefix': 'string',
'Delimiter': 'string',
'MaxKeys': 123,
'CommonPrefixes': [
{
'Prefix': 'string'
},
],
'EncodingType': 'url'
}
Response Structure
Returns some or all (up to 1000) of the objects in a bucket. You can use the request parameters as selection criteria to return a subset of the objects in a bucket.
See also: AWS API Documentation
Request Syntax
response = client.list_objects(
Bucket='string',
Delimiter='string',
EncodingType='url',
Marker='string',
MaxKeys=123,
Prefix='string',
RequestPayer='requester'
)
dict
Response Syntax
{
'IsTruncated': True|False,
'Marker': 'string',
'NextMarker': 'string',
'Contents': [
{
'Key': 'string',
'LastModified': datetime(2015, 1, 1),
'ETag': 'string',
'Size': 123,
'StorageClass': 'STANDARD'|'REDUCED_REDUNDANCY'|'GLACIER',
'Owner': {
'DisplayName': 'string',
'ID': 'string'
}
},
],
'Name': 'string',
'Prefix': 'string',
'Delimiter': 'string',
'MaxKeys': 123,
'CommonPrefixes': [
{
'Prefix': 'string'
},
],
'EncodingType': 'url'
}
Response Structure
Returns some or all (up to 1000) of the objects in a bucket. You can use the request parameters as selection criteria to return a subset of the objects in a bucket. Note: ListObjectsV2 is the revised List Objects API and we recommend you use this revised API for new application development.
See also: AWS API Documentation
Request Syntax
response = client.list_objects_v2(
Bucket='string',
Delimiter='string',
EncodingType='url',
MaxKeys=123,
Prefix='string',
ContinuationToken='string',
FetchOwner=True|False,
StartAfter='string',
RequestPayer='requester'
)
dict
Response Syntax
{
'IsTruncated': True|False,
'Contents': [
{
'Key': 'string',
'LastModified': datetime(2015, 1, 1),
'ETag': 'string',
'Size': 123,
'StorageClass': 'STANDARD'|'REDUCED_REDUNDANCY'|'GLACIER',
'Owner': {
'DisplayName': 'string',
'ID': 'string'
}
},
],
'Name': 'string',
'Prefix': 'string',
'Delimiter': 'string',
'MaxKeys': 123,
'CommonPrefixes': [
{
'Prefix': 'string'
},
],
'EncodingType': 'url',
'KeyCount': 123,
'ContinuationToken': 'string',
'NextContinuationToken': 'string',
'StartAfter': 'string'
}
Response Structure
Lists the parts that have been uploaded for a specific multipart upload.
See also: AWS API Documentation
Request Syntax
response = client.list_parts(
Bucket='string',
Key='string',
MaxParts=123,
PartNumberMarker=123,
UploadId='string',
RequestPayer='requester'
)
dict
Response Syntax
{
'AbortDate': datetime(2015, 1, 1),
'AbortRuleId': 'string',
'Bucket': 'string',
'Key': 'string',
'UploadId': 'string',
'PartNumberMarker': 123,
'NextPartNumberMarker': 123,
'MaxParts': 123,
'IsTruncated': True|False,
'Parts': [
{
'PartNumber': 123,
'LastModified': datetime(2015, 1, 1),
'ETag': 'string',
'Size': 123
},
],
'Initiator': {
'ID': 'string',
'DisplayName': 'string'
},
'Owner': {
'DisplayName': 'string',
'ID': 'string'
},
'StorageClass': 'STANDARD'|'REDUCED_REDUNDANCY'|'STANDARD_IA',
'RequestCharged': 'requester'
}
Response Structure
Sets the accelerate configuration of an existing bucket.
See also: AWS API Documentation
Request Syntax
response = client.put_bucket_accelerate_configuration(
Bucket='string',
AccelerateConfiguration={
'Status': 'Enabled'|'Suspended'
}
)
[REQUIRED] Specifies the Accelerate Configuration you want to set for the bucket.
None
Sets the permissions on a bucket using access control lists (ACL).
See also: AWS API Documentation
Request Syntax
response = client.put_bucket_acl(
ACL='private'|'public-read'|'public-read-write'|'authenticated-read',
AccessControlPolicy={
'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'
}
},
Bucket='string',
GrantFullControl='string',
GrantRead='string',
GrantReadACP='string',
GrantWrite='string',
GrantWriteACP='string'
)
None
Sets an analytics configuration for the bucket (specified by the analytics configuration ID).
See also: AWS API Documentation
Request Syntax
response = client.put_bucket_analytics_configuration(
Bucket='string',
Id='string',
AnalyticsConfiguration={
'Id': 'string',
'Filter': {
'Prefix': 'string',
'Tag': {
'Key': 'string',
'Value': 'string'
},
'And': {
'Prefix': 'string',
'Tags': [
{
'Key': 'string',
'Value': 'string'
},
]
}
},
'StorageClassAnalysis': {
'DataExport': {
'OutputSchemaVersion': 'V_1',
'Destination': {
'S3BucketDestination': {
'Format': 'CSV',
'BucketAccountId': 'string',
'Bucket': 'string',
'Prefix': 'string'
}
}
}
}
}
)
[REQUIRED] The configuration and any analyses for the analytics filter.
None
Sets the cors configuration for a bucket.
See also: AWS API Documentation
Request Syntax
response = client.put_bucket_cors(
Bucket='string',
CORSConfiguration={
'CORSRules': [
{
'AllowedHeaders': [
'string',
],
'AllowedMethods': [
'string',
],
'AllowedOrigins': [
'string',
],
'ExposeHeaders': [
'string',
],
'MaxAgeSeconds': 123
},
]
},
)
[REQUIRED]
None
Adds an inventory configuration (identified by the inventory ID) from the bucket.
See also: AWS API Documentation
Request Syntax
response = client.put_bucket_inventory_configuration(
Bucket='string',
Id='string',
InventoryConfiguration={
'Destination': {
'S3BucketDestination': {
'AccountId': 'string',
'Bucket': 'string',
'Format': 'CSV',
'Prefix': 'string'
}
},
'IsEnabled': True|False,
'Filter': {
'Prefix': 'string'
},
'Id': 'string',
'IncludedObjectVersions': 'All'|'Current',
'OptionalFields': [
'Size'|'LastModifiedDate'|'StorageClass'|'ETag'|'IsMultipartUploaded'|'ReplicationStatus',
],
'Schedule': {
'Frequency': 'Daily'|'Weekly'
}
}
)
[REQUIRED] Specifies the inventory configuration.
None
Deprecated, see the PutBucketLifecycleConfiguration operation.
See also: AWS API Documentation
Request Syntax
response = client.put_bucket_lifecycle(
Bucket='string',
LifecycleConfiguration={
'Rules': [
{
'Expiration': {
'Date': datetime(2015, 1, 1),
'Days': 123,
'ExpiredObjectDeleteMarker': True|False
},
'ID': 'string',
'Prefix': 'string',
'Status': 'Enabled'|'Disabled',
'Transition': {
'Date': datetime(2015, 1, 1),
'Days': 123,
'StorageClass': 'GLACIER'|'STANDARD_IA'
},
'NoncurrentVersionTransition': {
'NoncurrentDays': 123,
'StorageClass': 'GLACIER'|'STANDARD_IA'
},
'NoncurrentVersionExpiration': {
'NoncurrentDays': 123
},
'AbortIncompleteMultipartUpload': {
'DaysAfterInitiation': 123
}
},
]
}
)
None
Sets lifecycle configuration for your bucket. If a lifecycle configuration exists, it replaces it.
See also: AWS API Documentation
Request Syntax
response = client.put_bucket_lifecycle_configuration(
Bucket='string',
LifecycleConfiguration={
'Rules': [
{
'Expiration': {
'Date': datetime(2015, 1, 1),
'Days': 123,
'ExpiredObjectDeleteMarker': True|False
},
'ID': 'string',
'Prefix': 'string',
'Filter': {
'Prefix': 'string',
'Tag': {
'Key': 'string',
'Value': 'string'
},
'And': {
'Prefix': 'string',
'Tags': [
{
'Key': 'string',
'Value': 'string'
},
]
}
},
'Status': 'Enabled'|'Disabled',
'Transitions': [
{
'Date': datetime(2015, 1, 1),
'Days': 123,
'StorageClass': 'GLACIER'|'STANDARD_IA'
},
],
'NoncurrentVersionTransitions': [
{
'NoncurrentDays': 123,
'StorageClass': 'GLACIER'|'STANDARD_IA'
},
],
'NoncurrentVersionExpiration': {
'NoncurrentDays': 123
},
'AbortIncompleteMultipartUpload': {
'DaysAfterInitiation': 123
}
},
]
}
)
None
Set the logging parameters for a bucket and to specify permissions for who can view and modify the logging parameters. To set the logging status of a bucket, you must be the bucket owner.
See also: AWS API Documentation
Request Syntax
response = client.put_bucket_logging(
Bucket='string',
BucketLoggingStatus={
'LoggingEnabled': {
'TargetBucket': 'string',
'TargetGrants': [
{
'Grantee': {
'DisplayName': 'string',
'EmailAddress': 'string',
'ID': 'string',
'Type': 'CanonicalUser'|'AmazonCustomerByEmail'|'Group',
'URI': 'string'
},
'Permission': 'FULL_CONTROL'|'READ'|'WRITE'
},
],
'TargetPrefix': 'string'
}
},
)
[REQUIRED]
None
Sets a metrics configuration (specified by the metrics configuration ID) for the bucket.
See also: AWS API Documentation
Request Syntax
response = client.put_bucket_metrics_configuration(
Bucket='string',
Id='string',
MetricsConfiguration={
'Id': 'string',
'Filter': {
'Prefix': 'string',
'Tag': {
'Key': 'string',
'Value': 'string'
},
'And': {
'Prefix': 'string',
'Tags': [
{
'Key': 'string',
'Value': 'string'
},
]
}
}
}
)
[REQUIRED] Specifies the metrics configuration.
None
Deprecated, see the PutBucketNotificationConfiguraiton operation.
See also: AWS API Documentation
Request Syntax
response = client.put_bucket_notification(
Bucket='string',
NotificationConfiguration={
'TopicConfiguration': {
'Id': 'string',
'Events': [
's3:ReducedRedundancyLostObject'|'s3:ObjectCreated:*'|'s3:ObjectCreated:Put'|'s3:ObjectCreated:Post'|'s3:ObjectCreated:Copy'|'s3:ObjectCreated:CompleteMultipartUpload'|'s3:ObjectRemoved:*'|'s3:ObjectRemoved:Delete'|'s3:ObjectRemoved:DeleteMarkerCreated',
],
'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',
'Topic': 'string'
},
'QueueConfiguration': {
'Id': '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',
'Events': [
's3:ReducedRedundancyLostObject'|'s3:ObjectCreated:*'|'s3:ObjectCreated:Put'|'s3:ObjectCreated:Post'|'s3:ObjectCreated:Copy'|'s3:ObjectCreated:CompleteMultipartUpload'|'s3:ObjectRemoved:*'|'s3:ObjectRemoved:Delete'|'s3:ObjectRemoved:DeleteMarkerCreated',
],
'Queue': 'string'
},
'CloudFunctionConfiguration': {
'Id': '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',
'Events': [
's3:ReducedRedundancyLostObject'|'s3:ObjectCreated:*'|'s3:ObjectCreated:Put'|'s3:ObjectCreated:Post'|'s3:ObjectCreated:Copy'|'s3:ObjectCreated:CompleteMultipartUpload'|'s3:ObjectRemoved:*'|'s3:ObjectRemoved:Delete'|'s3:ObjectRemoved:DeleteMarkerCreated',
],
'CloudFunction': 'string',
'InvocationRole': 'string'
}
}
)
[REQUIRED]
None
Enables notifications of specified events for a bucket.
See also: AWS API Documentation
Request Syntax
response = client.put_bucket_notification_configuration(
Bucket='string',
NotificationConfiguration={
'TopicConfigurations': [
{
'Id': 'string',
'TopicArn': 'string',
'Events': [
's3:ReducedRedundancyLostObject'|'s3:ObjectCreated:*'|'s3:ObjectCreated:Put'|'s3:ObjectCreated:Post'|'s3:ObjectCreated:Copy'|'s3:ObjectCreated:CompleteMultipartUpload'|'s3:ObjectRemoved:*'|'s3:ObjectRemoved:Delete'|'s3:ObjectRemoved:DeleteMarkerCreated',
],
'Filter': {
'Key': {
'FilterRules': [
{
'Name': 'prefix'|'suffix',
'Value': 'string'
},
]
}
}
},
],
'QueueConfigurations': [
{
'Id': 'string',
'QueueArn': 'string',
'Events': [
's3:ReducedRedundancyLostObject'|'s3:ObjectCreated:*'|'s3:ObjectCreated:Put'|'s3:ObjectCreated:Post'|'s3:ObjectCreated:Copy'|'s3:ObjectCreated:CompleteMultipartUpload'|'s3:ObjectRemoved:*'|'s3:ObjectRemoved:Delete'|'s3:ObjectRemoved:DeleteMarkerCreated',
],
'Filter': {
'Key': {
'FilterRules': [
{
'Name': 'prefix'|'suffix',
'Value': 'string'
},
]
}
}
},
],
'LambdaFunctionConfigurations': [
{
'Id': 'string',
'LambdaFunctionArn': 'string',
'Events': [
's3:ReducedRedundancyLostObject'|'s3:ObjectCreated:*'|'s3:ObjectCreated:Put'|'s3:ObjectCreated:Post'|'s3:ObjectCreated:Copy'|'s3:ObjectCreated:CompleteMultipartUpload'|'s3:ObjectRemoved:*'|'s3:ObjectRemoved:Delete'|'s3:ObjectRemoved:DeleteMarkerCreated',
],
'Filter': {
'Key': {
'FilterRules': [
{
'Name': 'prefix'|'suffix',
'Value': 'string'
},
]
}
}
},
]
}
)
[REQUIRED] Container for specifying the notification configuration of the bucket. If this element is empty, notifications are turned off on the bucket.
None
Replaces a policy on a bucket. If the bucket already has a policy, the one in this request completely replaces it.
See also: AWS API Documentation
Request Syntax
response = client.put_bucket_policy(
Bucket='string',
Policy='string'
)
None
Creates a new replication configuration (or replaces an existing one, if present).
See also: AWS API Documentation
Request Syntax
response = client.put_bucket_replication(
Bucket='string',
ReplicationConfiguration={
'Role': 'string',
'Rules': [
{
'ID': 'string',
'Prefix': 'string',
'Status': 'Enabled'|'Disabled',
'Destination': {
'Bucket': 'string',
'StorageClass': 'STANDARD'|'REDUCED_REDUNDANCY'|'STANDARD_IA'
}
},
]
}
)
[REQUIRED] Container for replication rules. You can add as many as 1,000 rules. Total replication configuration size can be up to 2 MB.
None
Sets the request payment configuration for a bucket. By default, the bucket owner pays for downloads from the bucket. This configuration parameter enables the bucket owner (only) to specify that the person requesting the download will be charged for the download. Documentation on requester pays buckets can be found at http://docs.aws.amazon.com/AmazonS3/latest/dev/RequesterPaysBuckets.html
See also: AWS API Documentation
Request Syntax
response = client.put_bucket_request_payment(
Bucket='string',
RequestPaymentConfiguration={
'Payer': 'Requester'|'BucketOwner'
}
)
[REQUIRED]
None
Sets the tags for a bucket.
See also: AWS API Documentation
Request Syntax
response = client.put_bucket_tagging(
Bucket='string',
Tagging={
'TagSet': [
{
'Key': 'string',
'Value': 'string'
},
]
}
)
[REQUIRED]
None
Sets the versioning state of an existing bucket. To set the versioning state, you must be the bucket owner.
See also: AWS API Documentation
Request Syntax
response = client.put_bucket_versioning(
Bucket='string',
MFA='string',
VersioningConfiguration={
'MFADelete': 'Enabled'|'Disabled',
'Status': 'Enabled'|'Suspended'
}
)
[REQUIRED]
None
Set the website configuration for a bucket.
See also: AWS API Documentation
Request Syntax
response = client.put_bucket_website(
Bucket='string',
WebsiteConfiguration={
'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'
}
},
]
}
)
[REQUIRED]
None
Adds an object to a bucket.
See also: AWS API Documentation
Request Syntax
response = client.put_object(
ACL='private'|'public-read'|'public-read-write'|'authenticated-read'|'aws-exec-read'|'bucket-owner-read'|'bucket-owner-full-control',
Body=b'bytes'|file,
Bucket='string',
CacheControl='string',
ContentDisposition='string',
ContentEncoding='string',
ContentLanguage='string',
ContentLength=123,
ContentMD5='string',
ContentType='string',
Expires=datetime(2015, 1, 1),
GrantFullControl='string',
GrantRead='string',
GrantReadACP='string',
GrantWriteACP='string',
Key='string',
Metadata={
'string': 'string'
},
ServerSideEncryption='AES256'|'aws:kms',
StorageClass='STANDARD'|'REDUCED_REDUNDANCY'|'STANDARD_IA',
WebsiteRedirectLocation='string',
SSECustomerAlgorithm='string',
SSECustomerKey='string',
SSEKMSKeyId='string',
RequestPayer='requester',
Tagging='string'
)
A map of metadata to store with the object in S3.
dict
Response Syntax
{
'Expiration': 'string',
'ETag': 'string',
'ServerSideEncryption': 'AES256'|'aws:kms',
'VersionId': 'string',
'SSECustomerAlgorithm': 'string',
'SSECustomerKeyMD5': 'string',
'SSEKMSKeyId': 'string',
'RequestCharged': 'requester'
}
Response Structure
uses the acl subresource to set the access control list (ACL) permissions for an object that already exists in a bucket
See also: AWS API Documentation
Request Syntax
response = client.put_object_acl(
ACL='private'|'public-read'|'public-read-write'|'authenticated-read'|'aws-exec-read'|'bucket-owner-read'|'bucket-owner-full-control',
AccessControlPolicy={
'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'
}
},
Bucket='string',
GrantFullControl='string',
GrantRead='string',
GrantReadACP='string',
GrantWrite='string',
GrantWriteACP='string',
Key='string',
RequestPayer='requester',
VersionId='string'
)
dict
Response Syntax
{
'RequestCharged': 'requester'
}
Response Structure
Sets the supplied tag-set to an object that already exists in a bucket
See also: AWS API Documentation
Request Syntax
response = client.put_object_tagging(
Bucket='string',
Key='string',
VersionId='string',
ContentMD5='string',
Tagging={
'TagSet': [
{
'Key': 'string',
'Value': 'string'
},
]
}
)
[REQUIRED]
dict
Response Syntax
{
'VersionId': 'string'
}
Response Structure
Restores an archived copy of an object back into Amazon S3
See also: AWS API Documentation
Request Syntax
response = client.restore_object(
Bucket='string',
Key='string',
VersionId='string',
RestoreRequest={
'Days': 123,
'GlacierJobParameters': {
'Tier': 'Standard'|'Bulk'|'Expedited'
}
},
RequestPayer='requester'
)
dict
Response Syntax
{
'RequestCharged': 'requester'
}
Response Structure
Upload a file to an S3 object.
Usage:
import boto3
s3 = boto3.resource('s3')
s3.meta.client.upload_file('/tmp/hello.txt', 'mybucket', 'hello.txt')
Similar behavior as S3Transfer's upload_file() method, except that parameters are capitalized. Detailed examples can be found at S3Transfer's Usage.
Upload a file-like object to S3.
The file-like object must be in binary mode.
This is a managed transfer which will perform a multipart upload in multiple threads if necessary.
Usage:
import boto3
s3 = boto3.client('s3')
with open('filename', 'rb') as data:
s3.upload_fileobj(data, 'mybucket', 'mykey')
Uploads a part in a multipart upload.
Note: After you initiate multipart upload and upload one or more parts, you must either complete or abort multipart upload in order to stop getting charged for storage of the uploaded parts. Only after you either complete or abort multipart upload, Amazon S3 frees up the parts storage and stops charging you for the parts storage.
See also: AWS API Documentation
Request Syntax
response = client.upload_part(
Body=b'bytes'|file,
Bucket='string',
ContentLength=123,
ContentMD5='string',
Key='string',
PartNumber=123,
UploadId='string',
SSECustomerAlgorithm='string',
SSECustomerKey='string',
RequestPayer='requester'
)
dict
Response Syntax
{
'ServerSideEncryption': 'AES256'|'aws:kms',
'ETag': 'string',
'SSECustomerAlgorithm': 'string',
'SSECustomerKeyMD5': 'string',
'SSEKMSKeyId': 'string',
'RequestCharged': 'requester'
}
Response Structure
Uploads a part by copying data from an existing object as data source.
See also: AWS API Documentation
Request Syntax
response = client.upload_part_copy(
Bucket='string',
CopySource='string' or {'Bucket': 'string', 'Key': 'string', 'VersionId': 'string'},
CopySourceIfMatch='string',
CopySourceIfModifiedSince=datetime(2015, 1, 1),
CopySourceIfNoneMatch='string',
CopySourceIfUnmodifiedSince=datetime(2015, 1, 1),
CopySourceRange='string',
Key='string',
PartNumber=123,
UploadId='string',
SSECustomerAlgorithm='string',
SSECustomerKey='string',
CopySourceSSECustomerAlgorithm='string',
CopySourceSSECustomerKey='string',
RequestPayer='requester'
)
dict
Response Syntax
{
'CopySourceVersionId': 'string',
'CopyPartResult': {
'ETag': 'string',
'LastModified': datetime(2015, 1, 1)
},
'ServerSideEncryption': 'AES256'|'aws:kms',
'SSECustomerAlgorithm': 'string',
'SSECustomerKeyMD5': 'string',
'SSEKMSKeyId': 'string',
'RequestCharged': 'requester'
}
Response Structure
The available paginators are:
paginator = client.get_paginator('list_multipart_uploads')
Creates an iterator that will paginate through responses from S3.Client.list_multipart_uploads().
See also: AWS API Documentation
Request Syntax
response_iterator = paginator.paginate(
Bucket='string',
Delimiter='string',
EncodingType='url',
Prefix='string',
PaginationConfig={
'MaxItems': 123,
'PageSize': 123,
'StartingToken': 'string'
}
)
A dictionary that provides parameters to control pagination.
The total number of items to return. If the total number of items available is more than the value specified in max-items then a NextToken will be provided in the output that you can use to resume pagination.
The size of each page.
A token to specify where to start paginating. This is the NextToken from a previous response.
dict
Response Syntax
{
'Bucket': 'string',
'KeyMarker': 'string',
'UploadIdMarker': 'string',
'Prefix': 'string',
'Delimiter': 'string',
'MaxUploads': 123,
'IsTruncated': True|False,
'Uploads': [
{
'UploadId': 'string',
'Key': 'string',
'Initiated': datetime(2015, 1, 1),
'StorageClass': 'STANDARD'|'REDUCED_REDUNDANCY'|'STANDARD_IA',
'Owner': {
'DisplayName': 'string',
'ID': 'string'
},
'Initiator': {
'ID': 'string',
'DisplayName': 'string'
}
},
],
'CommonPrefixes': [
{
'Prefix': 'string'
},
],
'EncodingType': 'url',
'NextToken': 'string'
}
Response Structure
(dict) --
Bucket (string) -- Name of the bucket to which the multipart upload was initiated.
KeyMarker (string) -- The key at or after which the listing began.
UploadIdMarker (string) -- Upload ID after which listing began.
Prefix (string) -- When a prefix is provided in the request, this field contains the specified prefix. The result contains only keys starting with the specified prefix.
Delimiter (string) --
MaxUploads (integer) -- Maximum number of multipart uploads that could have been included in the response.
IsTruncated (boolean) -- Indicates whether the returned list of multipart uploads is truncated. A value of true indicates that the list was truncated. The list can be truncated if the number of multipart uploads exceeds the limit allowed or specified by max uploads.
Uploads (list) --
CommonPrefixes (list) --
EncodingType (string) -- Encoding type used by Amazon S3 to encode object keys in the response.
NextToken (string) --
A token to resume pagination.
paginator = client.get_paginator('list_object_versions')
Creates an iterator that will paginate through responses from S3.Client.list_object_versions().
See also: AWS API Documentation
Request Syntax
response_iterator = paginator.paginate(
Bucket='string',
Delimiter='string',
EncodingType='url',
Prefix='string',
PaginationConfig={
'MaxItems': 123,
'PageSize': 123,
'StartingToken': 'string'
}
)
A dictionary that provides parameters to control pagination.
The total number of items to return. If the total number of items available is more than the value specified in max-items then a NextToken will be provided in the output that you can use to resume pagination.
The size of each page.
A token to specify where to start paginating. This is the NextToken from a previous response.
dict
Response Syntax
{
'IsTruncated': True|False,
'KeyMarker': 'string',
'VersionIdMarker': 'string',
'Versions': [
{
'ETag': 'string',
'Size': 123,
'StorageClass': 'STANDARD',
'Key': 'string',
'VersionId': 'string',
'IsLatest': True|False,
'LastModified': datetime(2015, 1, 1),
'Owner': {
'DisplayName': 'string',
'ID': 'string'
}
},
],
'DeleteMarkers': [
{
'Owner': {
'DisplayName': 'string',
'ID': 'string'
},
'Key': 'string',
'VersionId': 'string',
'IsLatest': True|False,
'LastModified': datetime(2015, 1, 1)
},
],
'Name': 'string',
'Prefix': 'string',
'Delimiter': 'string',
'MaxKeys': 123,
'CommonPrefixes': [
{
'Prefix': 'string'
},
],
'EncodingType': 'url',
'NextToken': 'string'
}
Response Structure
(dict) --
IsTruncated (boolean) -- A flag that indicates whether or not Amazon S3 returned all of the results that satisfied the search criteria. If your results were truncated, you can make a follow-up paginated request using the NextKeyMarker and NextVersionIdMarker response parameters as a starting place in another request to return the rest of the results.
KeyMarker (string) -- Marks the last Key returned in a truncated response.
VersionIdMarker (string) --
Versions (list) --
DeleteMarkers (list) --
Name (string) --
Prefix (string) --
Delimiter (string) --
MaxKeys (integer) --
CommonPrefixes (list) --
EncodingType (string) -- Encoding type used by Amazon S3 to encode object keys in the response.
NextToken (string) --
A token to resume pagination.
paginator = client.get_paginator('list_objects')
Creates an iterator that will paginate through responses from S3.Client.list_objects().
See also: AWS API Documentation
Request Syntax
response_iterator = paginator.paginate(
Bucket='string',
Delimiter='string',
EncodingType='url',
Prefix='string',
RequestPayer='requester',
PaginationConfig={
'MaxItems': 123,
'PageSize': 123,
'StartingToken': 'string'
}
)
A dictionary that provides parameters to control pagination.
The total number of items to return. If the total number of items available is more than the value specified in max-items then a NextToken will be provided in the output that you can use to resume pagination.
The size of each page.
A token to specify where to start paginating. This is the NextToken from a previous response.
dict
Response Syntax
{
'IsTruncated': True|False,
'Marker': 'string',
'NextMarker': 'string',
'Contents': [
{
'Key': 'string',
'LastModified': datetime(2015, 1, 1),
'ETag': 'string',
'Size': 123,
'StorageClass': 'STANDARD'|'REDUCED_REDUNDANCY'|'GLACIER',
'Owner': {
'DisplayName': 'string',
'ID': 'string'
}
},
],
'Name': 'string',
'Prefix': 'string',
'Delimiter': 'string',
'MaxKeys': 123,
'CommonPrefixes': [
{
'Prefix': 'string'
},
],
'EncodingType': 'url',
'NextToken': 'string'
}
Response Structure
(dict) --
IsTruncated (boolean) -- A flag that indicates whether or not Amazon S3 returned all of the results that satisfied the search criteria.
Marker (string) --
NextMarker (string) -- When response is truncated (the IsTruncated element value in the response is true), you can use the key name in this field as marker in the subsequent request to get next set of objects. Amazon S3 lists objects in alphabetical order Note: This element is returned only if you have delimiter request parameter specified. If response does not include the NextMaker and it is truncated, you can use the value of the last Key in the response as the marker in the subsequent request to get the next set of object keys.
Contents (list) --
Name (string) --
Prefix (string) --
Delimiter (string) --
MaxKeys (integer) --
CommonPrefixes (list) --
EncodingType (string) -- Encoding type used by Amazon S3 to encode object keys in the response.
NextToken (string) --
A token to resume pagination.
paginator = client.get_paginator('list_objects_v2')
Creates an iterator that will paginate through responses from S3.Client.list_objects_v2().
See also: AWS API Documentation
Request Syntax
response_iterator = paginator.paginate(
Bucket='string',
Delimiter='string',
EncodingType='url',
Prefix='string',
FetchOwner=True|False,
StartAfter='string',
RequestPayer='requester',
PaginationConfig={
'MaxItems': 123,
'PageSize': 123,
'StartingToken': 'string'
}
)
A dictionary that provides parameters to control pagination.
The total number of items to return. If the total number of items available is more than the value specified in max-items then a NextToken will be provided in the output that you can use to resume pagination.
The size of each page.
A token to specify where to start paginating. This is the NextToken from a previous response.
dict
Response Syntax
{
'IsTruncated': True|False,
'Contents': [
{
'Key': 'string',
'LastModified': datetime(2015, 1, 1),
'ETag': 'string',
'Size': 123,
'StorageClass': 'STANDARD'|'REDUCED_REDUNDANCY'|'GLACIER',
'Owner': {
'DisplayName': 'string',
'ID': 'string'
}
},
],
'Name': 'string',
'Prefix': 'string',
'Delimiter': 'string',
'MaxKeys': 123,
'CommonPrefixes': [
{
'Prefix': 'string'
},
],
'EncodingType': 'url',
'KeyCount': 123,
'ContinuationToken': 'string',
'StartAfter': 'string',
'NextToken': 'string'
}
Response Structure
(dict) --
IsTruncated (boolean) -- A flag that indicates whether or not Amazon S3 returned all of the results that satisfied the search criteria.
Contents (list) -- Metadata about each object returned.
Name (string) -- Name of the bucket to list.
Prefix (string) -- Limits the response to keys that begin with the specified prefix.
Delimiter (string) -- A delimiter is a character you use to group keys.
MaxKeys (integer) -- Sets the maximum number of keys returned in the response. The response might contain fewer keys but will never contain more.
CommonPrefixes (list) -- CommonPrefixes contains all (if there are any) keys between Prefix and the next occurrence of the string specified by delimiter
EncodingType (string) -- Encoding type used by Amazon S3 to encode object keys in the response.
KeyCount (integer) -- KeyCount is the number of keys returned with this request. KeyCount will always be less than equals to MaxKeys field. Say you ask for 50 keys, your result will include less than equals 50 keys
ContinuationToken (string) -- ContinuationToken indicates Amazon S3 that the list is being continued on this bucket with a token. ContinuationToken is obfuscated and is not a real key
StartAfter (string) -- StartAfter is where you want Amazon S3 to start listing from. Amazon S3 starts listing after this specified key. StartAfter can be any key in the bucket
NextToken (string) --
A token to resume pagination.
paginator = client.get_paginator('list_parts')
Creates an iterator that will paginate through responses from S3.Client.list_parts().
See also: AWS API Documentation
Request Syntax
response_iterator = paginator.paginate(
Bucket='string',
Key='string',
UploadId='string',
RequestPayer='requester',
PaginationConfig={
'MaxItems': 123,
'PageSize': 123,
'StartingToken': 'string'
}
)
A dictionary that provides parameters to control pagination.
The total number of items to return. If the total number of items available is more than the value specified in max-items then a NextToken will be provided in the output that you can use to resume pagination.
The size of each page.
A token to specify where to start paginating. This is the NextToken from a previous response.
dict
Response Syntax
{
'AbortDate': datetime(2015, 1, 1),
'AbortRuleId': 'string',
'Bucket': 'string',
'Key': 'string',
'UploadId': 'string',
'PartNumberMarker': 123,
'MaxParts': 123,
'IsTruncated': True|False,
'Parts': [
{
'PartNumber': 123,
'LastModified': datetime(2015, 1, 1),
'ETag': 'string',
'Size': 123
},
],
'Initiator': {
'ID': 'string',
'DisplayName': 'string'
},
'Owner': {
'DisplayName': 'string',
'ID': 'string'
},
'StorageClass': 'STANDARD'|'REDUCED_REDUNDANCY'|'STANDARD_IA',
'RequestCharged': 'requester',
'NextToken': 'string'
}
Response Structure
(dict) --
AbortDate (datetime) -- Date when multipart upload will become eligible for abort operation by lifecycle.
AbortRuleId (string) -- Id of the lifecycle rule that makes a multipart upload eligible for abort operation.
Bucket (string) -- Name of the bucket to which the multipart upload was initiated.
Key (string) -- Object key for which the multipart upload was initiated.
UploadId (string) -- Upload ID identifying the multipart upload whose parts are being listed.
PartNumberMarker (integer) -- Part number after which listing begins.
MaxParts (integer) -- Maximum number of parts that were allowed in the response.
IsTruncated (boolean) -- Indicates whether the returned list of parts is truncated.
Parts (list) --
Initiator (dict) -- Identifies who initiated the multipart upload.
Owner (dict) --
StorageClass (string) -- The class of storage used to store the object.
RequestCharged (string) -- If present, indicates that the requester was successfully charged for the request.
NextToken (string) --
A token to resume pagination.
The available waiters are:
waiter = client.get_waiter('bucket_exists')
Polls S3.Client.head_bucket() every 5 seconds until a successful state is reached. An error is returned after 20 failed checks.
See also: AWS API Documentation
Request Syntax
waiter.wait(
Bucket='string'
)
waiter = client.get_waiter('bucket_not_exists')
Polls S3.Client.head_bucket() every 5 seconds until a successful state is reached. An error is returned after 20 failed checks.
See also: AWS API Documentation
Request Syntax
waiter.wait(
Bucket='string'
)
waiter = client.get_waiter('object_exists')
Polls S3.Client.head_object() every 5 seconds until a successful state is reached. An error is returned after 20 failed checks.
See also: AWS API Documentation
Request Syntax
waiter.wait(
Bucket='string',
IfMatch='string',
IfModifiedSince=datetime(2015, 1, 1),
IfNoneMatch='string',
IfUnmodifiedSince=datetime(2015, 1, 1),
Key='string',
Range='string',
VersionId='string',
SSECustomerAlgorithm='string',
SSECustomerKey='string',
RequestPayer='requester',
PartNumber=123
)
None
waiter = client.get_waiter('object_not_exists')
Polls S3.Client.head_object() every 5 seconds until a successful state is reached. An error is returned after 20 failed checks.
See also: AWS API Documentation
Request Syntax
waiter.wait(
Bucket='string',
IfMatch='string',
IfModifiedSince=datetime(2015, 1, 1),
IfNoneMatch='string',
IfUnmodifiedSince=datetime(2015, 1, 1),
Key='string',
Range='string',
VersionId='string',
SSECustomerAlgorithm='string',
SSECustomerKey='string',
RequestPayer='requester',
PartNumber=123
)
None
A resource representing Amazon Simple Storage Service (S3):
import boto3
s3 = boto3.resource('s3')
These are the resource's available actions:
These are the resource's available sub-resources:
These are the resource's available collections:
Actions
Actions call operations on resources. They may automatically handle the passing in of arguments set from identifiers and some attributes. For more information about actions refer to the Resources Introduction Guide.
Creates a new bucket.
See also: AWS API Documentation
Request Syntax
bucket = s3.create_bucket(
ACL='private'|'public-read'|'public-read-write'|'authenticated-read',
Bucket='string',
CreateBucketConfiguration={
'LocationConstraint': 'EU'|'eu-west-1'|'us-west-1'|'us-west-2'|'ap-south-1'|'ap-southeast-1'|'ap-southeast-2'|'ap-northeast-1'|'sa-east-1'|'cn-north-1'|'eu-central-1'
},
GrantFullControl='string',
GrantRead='string',
GrantReadACP='string',
GrantWrite='string',
GrantWriteACP='string'
)
s3.Bucket
Bucket resource
Returns a list of all the available sub-resources for this Resource.
Sub-resources
Sub-resources are methods that create a new instance of a child resource. This resource's identifiers get passed along to the child. For more information about sub-resources refer to the Resources Introduction Guide.
Creates a Bucket resource.:
bucket = s3.Bucket('name')
Creates a BucketAcl resource.:
bucket_acl = s3.BucketAcl('bucket_name')
Creates a BucketCors resource.:
bucket_cors = s3.BucketCors('bucket_name')
Creates a BucketLifecycle resource.:
bucket_lifecycle = s3.BucketLifecycle('bucket_name')
Creates a BucketLogging resource.:
bucket_logging = s3.BucketLogging('bucket_name')
Creates a BucketNotification resource.:
bucket_notification = s3.BucketNotification('bucket_name')
Creates a BucketPolicy resource.:
bucket_policy = s3.BucketPolicy('bucket_name')
Creates a BucketRequestPayment resource.:
bucket_request_payment = s3.BucketRequestPayment('bucket_name')
Creates a BucketTagging resource.:
bucket_tagging = s3.BucketTagging('bucket_name')
Creates a BucketVersioning resource.:
bucket_versioning = s3.BucketVersioning('bucket_name')
Creates a BucketWebsite resource.:
bucket_website = s3.BucketWebsite('bucket_name')
Creates a MultipartUpload resource.:
multipart_upload = s3.MultipartUpload('bucket_name','object_key','id')
A MultipartUpload resource
Creates a MultipartUploadPart resource.:
multipart_upload_part = s3.MultipartUploadPart('bucket_name','object_key','multipart_upload_id','part_number')
A MultipartUploadPart resource
Creates a Object resource.:
object = s3.Object('bucket_name','key')
A Object resource
Creates a ObjectAcl resource.:
object_acl = s3.ObjectAcl('bucket_name','object_key')
A ObjectAcl resource
Creates a ObjectSummary resource.:
object_summary = s3.ObjectSummary('bucket_name','key')
A ObjectSummary resource
Creates a ObjectVersion resource.:
object_version = s3.ObjectVersion('bucket_name','object_key','id')
A ObjectVersion resource
Collections
Collections provide an interface to iterate over and manipulate groups of resources. For more information about collections refer to the Resources Introduction Guide.
A collection of Bucket resources
Creates an iterable of all Bucket resources in the collection.
See also: AWS API Documentation
Request Syntax
bucket_iterator = s3.buckets.all()
Creates an iterable of all Bucket resources in the collection filtered by kwargs passed to method.
See also: AWS API Documentation
Request Syntax
bucket_iterator = s3.buckets.filter()
Creates an iterable up to a specified amount of Bucket resources in the collection.
See also: AWS API Documentation
Request Syntax
bucket_iterator = s3.buckets.limit()
Creates an iterable of all Bucket resources in the collection, but limits the number of items returned by each service call by the specified amount.
See also: AWS API Documentation
Request Syntax
bucket_iterator = s3.buckets.page_size()
A resource representing an Amazon Simple Storage Service (S3) Bucket:
import boto3
s3 = boto3.resource('s3')
bucket = s3.Bucket('name')
These are the resource's available identifiers:
These are the resource's available attributes:
These are the resource's available actions:
These are the resource's available sub-resources:
These are the resource's available collections:
These are the resource's available waiters:
Identifiers
Identifiers are properties of a resource that are set upon instantation of the resource. For more information about identifiers refer to the Resources Introduction Guide.
(string) The Bucket's name identifier. This must be set.
Attributes
Attributes provide access to the properties of a resource. Attributes are lazy-loaded the first time one is accessed via the load() method. For more information about attributes refer to the Resources Introduction Guide.
Actions
Actions call operations on resources. They may automatically handle the passing in of arguments set from identifiers and some attributes. For more information about actions refer to the Resources Introduction Guide.
Copy an object from one S3 location to an object in this bucket.
This is a managed transfer which will perform a multipart copy in multiple threads if necessary.
Usage:
import boto3
s3 = boto3.resource('s3')
copy_source = {
'Bucket': 'mybucket',
'Key': 'mykey'
}
bucket = s3.Bucket('otherbucket')
bucket.copy(copy_source, 'otherkey')
Creates a new bucket.
See also: AWS API Documentation
Request Syntax
response = bucket.create(
ACL='private'|'public-read'|'public-read-write'|'authenticated-read',
CreateBucketConfiguration={
'LocationConstraint': 'EU'|'eu-west-1'|'us-west-1'|'us-west-2'|'ap-south-1'|'ap-southeast-1'|'ap-southeast-2'|'ap-northeast-1'|'sa-east-1'|'cn-north-1'|'eu-central-1'
},
GrantFullControl='string',
GrantRead='string',
GrantReadACP='string',
GrantWrite='string',
GrantWriteACP='string'
)
dict
Response Syntax
{
'Location': 'string'
}
Response Structure
Deletes the bucket. All objects (including all object versions and Delete Markers) in the bucket must be deleted before the bucket itself can be deleted.
See also: AWS API Documentation
Request Syntax
response = bucket.delete()
This operation enables you to delete multiple objects from a bucket using a single HTTP request. You may specify up to 1000 keys.
See also: AWS API Documentation
Request Syntax
response = bucket.delete_objects(
Delete={
'Objects': [
{
'Key': 'string',
'VersionId': 'string'
},
],
'Quiet': True|False
},
MFA='string',
RequestPayer='requester'
)
[REQUIRED]
dict
Response Syntax
{
'Deleted': [
{
'Key': 'string',
'VersionId': 'string',
'DeleteMarker': True|False,
'DeleteMarkerVersionId': 'string'
},
],
'RequestCharged': 'requester',
'Errors': [
{
'Key': 'string',
'VersionId': 'string',
'Code': 'string',
'Message': 'string'
},
]
}
Response Structure
Download an S3 object to a file.
Usage:
import boto3
s3 = boto3.resource('s3')
s3.Bucket('mybucket').download_file('hello.txt', '/tmp/hello.txt')
Similar behavior as S3Transfer's download_file() method, except that parameters are capitalized. Detailed examples can be found at S3Transfer's Usage.
Download an object from this bucket to a file-like-object.
The file-like object must be in binary mode.
This is a managed transfer which will perform a multipart download in multiple threads if necessary.
Usage:
import boto3
s3 = boto3.resource('s3')
bucket = s3.Bucket('mybucket')
with open('filename', 'wb') as data:
bucket.download_fileobj('mykey', data)
Returns a list of all the available sub-resources for this Resource.
Calls s3.Client.list_buckets() to update the attributes of the Bucket resource.
Adds an object to a bucket.
See also: AWS API Documentation
Request Syntax
object = bucket.put_object(
ACL='private'|'public-read'|'public-read-write'|'authenticated-read'|'aws-exec-read'|'bucket-owner-read'|'bucket-owner-full-control',
Body=b'bytes'|file,
CacheControl='string',
ContentDisposition='string',
ContentEncoding='string',
ContentLanguage='string',
ContentLength=123,
ContentMD5='string',
ContentType='string',
Expires=datetime(2015, 1, 1),
GrantFullControl='string',
GrantRead='string',
GrantReadACP='string',
GrantWriteACP='string',
Key='string',
Metadata={
'string': 'string'
},
ServerSideEncryption='AES256'|'aws:kms',
StorageClass='STANDARD'|'REDUCED_REDUNDANCY'|'STANDARD_IA',
WebsiteRedirectLocation='string',
SSECustomerAlgorithm='string',
SSECustomerKey='string',
SSEKMSKeyId='string',
RequestPayer='requester',
Tagging='string'
)
A map of metadata to store with the object in S3.
s3.Object
Object resource
Upload a file to an S3 object.
Usage:
import boto3
s3 = boto3.resource('s3')
s3.Bucket('mybucket').upload_file('/tmp/hello.txt', 'hello.txt')
Similar behavior as S3Transfer's upload_file() method, except that parameters are capitalized. Detailed examples can be found at S3Transfer's Usage.
Upload a file-like object to this bucket.
The file-like object must be in binary mode.
This is a managed transfer which will perform a multipart upload in multiple threads if necessary.
Usage:
import boto3
s3 = boto3.resource('s3')
bucket = s3.Bucket('mybucket')
with open('filename', 'rb') as data:
bucket.upload_fileobj(data, 'mykey')
Sub-resources
Sub-resources are methods that create a new instance of a child resource. This resource's identifiers get passed along to the child. For more information about sub-resources refer to the Resources Introduction Guide.
Creates a BucketAcl resource.:
bucket_acl = bucket.Acl()
Creates a BucketCors resource.:
bucket_cors = bucket.Cors()
Creates a BucketLifecycle resource.:
bucket_lifecycle = bucket.Lifecycle()
Creates a BucketLogging resource.:
bucket_logging = bucket.Logging()
Creates a BucketNotification resource.:
bucket_notification = bucket.Notification()
Creates a Object resource.:
object = bucket.Object('key')
Creates a BucketPolicy resource.:
bucket_policy = bucket.Policy()
Creates a BucketRequestPayment resource.:
bucket_request_payment = bucket.RequestPayment()
Creates a BucketTagging resource.:
bucket_tagging = bucket.Tagging()
Creates a BucketVersioning resource.:
bucket_versioning = bucket.Versioning()
Creates a BucketWebsite resource.:
bucket_website = bucket.Website()
Collections
Collections provide an interface to iterate over and manipulate groups of resources. For more information about collections refer to the Resources Introduction Guide.
A collection of MultipartUpload resources
Creates an iterable of all MultipartUpload resources in the collection.
See also: AWS API Documentation
Request Syntax
multipart_upload_iterator = bucket.multipart_uploads.all()
Creates an iterable of all MultipartUpload resources in the collection filtered by kwargs passed to method.
See also: AWS API Documentation
Request Syntax
multipart_upload_iterator = bucket.multipart_uploads.filter(
Delimiter='string',
EncodingType='url',
KeyMarker='string',
MaxUploads=123,
Prefix='string',
UploadIdMarker='string'
)
list(s3.MultipartUpload)
A list of MultipartUpload resources
Creates an iterable up to a specified amount of MultipartUpload resources in the collection.
See also: AWS API Documentation
Request Syntax
multipart_upload_iterator = bucket.multipart_uploads.limit(
count=123
)
Creates an iterable of all MultipartUpload resources in the collection, but limits the number of items returned by each service call by the specified amount.
See also: AWS API Documentation
Request Syntax
multipart_upload_iterator = bucket.multipart_uploads.page_size(
count=123
)
A collection of ObjectVersion resources
Creates an iterable of all ObjectVersion resources in the collection.
See also: AWS API Documentation
Request Syntax
object_version_iterator = bucket.object_versions.all()
This operation enables you to delete multiple objects from a bucket using a single HTTP request. You may specify up to 1000 keys.
See also: AWS API Documentation
Request Syntax
response = bucket.object_versions.delete(
MFA='string',
RequestPayer='requester'
)
dict
Response Syntax
{
'Deleted': [
{
'Key': 'string',
'VersionId': 'string',
'DeleteMarker': True|False,
'DeleteMarkerVersionId': 'string'
},
],
'RequestCharged': 'requester',
'Errors': [
{
'Key': 'string',
'VersionId': 'string',
'Code': 'string',
'Message': 'string'
},
]
}
Response Structure
Creates an iterable of all ObjectVersion resources in the collection filtered by kwargs passed to method.
See also: AWS API Documentation
Request Syntax
object_version_iterator = bucket.object_versions.filter(
Delimiter='string',
EncodingType='url',
KeyMarker='string',
MaxKeys=123,
Prefix='string',
VersionIdMarker='string'
)
list(s3.ObjectVersion)
A list of ObjectVersion resources
Creates an iterable up to a specified amount of ObjectVersion resources in the collection.
See also: AWS API Documentation
Request Syntax
object_version_iterator = bucket.object_versions.limit(
count=123
)
Creates an iterable of all ObjectVersion resources in the collection, but limits the number of items returned by each service call by the specified amount.
See also: AWS API Documentation
Request Syntax
object_version_iterator = bucket.object_versions.page_size(
count=123
)
A collection of ObjectSummary resources
Creates an iterable of all ObjectSummary resources in the collection.
See also: AWS API Documentation
Request Syntax
object_summary_iterator = bucket.objects.all()
This operation enables you to delete multiple objects from a bucket using a single HTTP request. You may specify up to 1000 keys.
See also: AWS API Documentation
Request Syntax
response = bucket.objects.delete(
MFA='string',
RequestPayer='requester'
)
dict
Response Syntax
{
'Deleted': [
{
'Key': 'string',
'VersionId': 'string',
'DeleteMarker': True|False,
'DeleteMarkerVersionId': 'string'
},
],
'RequestCharged': 'requester',
'Errors': [
{
'Key': 'string',
'VersionId': 'string',
'Code': 'string',
'Message': 'string'
},
]
}
Response Structure
Creates an iterable of all ObjectSummary resources in the collection filtered by kwargs passed to method.
See also: AWS API Documentation
Request Syntax
object_summary_iterator = bucket.objects.filter(
Delimiter='string',
EncodingType='url',
Marker='string',
MaxKeys=123,
Prefix='string',
RequestPayer='requester'
)
list(s3.ObjectSummary)
A list of ObjectSummary resources
Creates an iterable up to a specified amount of ObjectSummary resources in the collection.
See also: AWS API Documentation
Request Syntax
object_summary_iterator = bucket.objects.limit(
count=123
)
Creates an iterable of all ObjectSummary resources in the collection, but limits the number of items returned by each service call by the specified amount.
See also: AWS API Documentation
Request Syntax
object_summary_iterator = bucket.objects.page_size(
count=123
)
Waiters
Waiters provide an interface to wait for a resource to reach a specific state. For more information about waiters refer to the Resources Introduction Guide.
Waits until this Bucket is exists. This method calls S3.Waiter.bucket_exists.wait() which polls. S3.Client.head_bucket() every 5 seconds until a successful state is reached. An error is returned after 20 failed checks.
See also: AWS API Documentation
Request Syntax
bucket.wait_until_exists()
Waits until this Bucket is not exists. This method calls S3.Waiter.bucket_not_exists.wait() which polls. S3.Client.head_bucket() every 5 seconds until a successful state is reached. An error is returned after 20 failed checks.
See also: AWS API Documentation
Request Syntax
bucket.wait_until_not_exists()
A resource representing an Amazon Simple Storage Service (S3) BucketAcl:
import boto3
s3 = boto3.resource('s3')
bucket_acl = s3.BucketAcl('bucket_name')
These are the resource's available identifiers:
These are the resource's available attributes:
These are the resource's available actions:
These are the resource's available sub-resources:
Identifiers
Identifiers are properties of a resource that are set upon instantation of the resource. For more information about identifiers refer to the Resources Introduction Guide.
(string) The BucketAcl's bucket_name identifier. This must be set.
Attributes
Attributes provide access to the properties of a resource. Attributes are lazy-loaded the first time one is accessed via the load() method. For more information about attributes refer to the Resources Introduction Guide.
Actions
Actions call operations on resources. They may automatically handle the passing in of arguments set from identifiers and some attributes. For more information about actions refer to the Resources Introduction Guide.
Returns a list of all the available sub-resources for this Resource.
Calls S3.Client.get_bucket_acl() to update the attributes of the BucketAcl resource. Note that the load and reload methods are the same method and can be used interchangeably.
See also: AWS API Documentation
Request Syntax
bucket_acl.load()
Sets the permissions on a bucket using access control lists (ACL).
See also: AWS API Documentation
Request Syntax
response = bucket_acl.put(
ACL='private'|'public-read'|'public-read-write'|'authenticated-read',
AccessControlPolicy={
'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'
}
},
GrantFullControl='string',
GrantRead='string',
GrantReadACP='string',
GrantWrite='string',
GrantWriteACP='string'
)
None
Calls S3.Client.get_bucket_acl() to update the attributes of the BucketAcl resource. Note that the load and reload methods are the same method and can be used interchangeably.
See also: AWS API Documentation
Request Syntax
bucket_acl.reload()
Sub-resources
Sub-resources are methods that create a new instance of a child resource. This resource's identifiers get passed along to the child. For more information about sub-resources refer to the Resources Introduction Guide.
A resource representing an Amazon Simple Storage Service (S3) BucketCors:
import boto3
s3 = boto3.resource('s3')
bucket_cors = s3.BucketCors('bucket_name')
These are the resource's available identifiers:
These are the resource's available attributes:
These are the resource's available actions:
These are the resource's available sub-resources:
Identifiers
Identifiers are properties of a resource that are set upon instantation of the resource. For more information about identifiers refer to the Resources Introduction Guide.
(string) The BucketCors's bucket_name identifier. This must be set.
Attributes
Attributes provide access to the properties of a resource. Attributes are lazy-loaded the first time one is accessed via the load() method. For more information about attributes refer to the Resources Introduction Guide.
Actions
Actions call operations on resources. They may automatically handle the passing in of arguments set from identifiers and some attributes. For more information about actions refer to the Resources Introduction Guide.
Deletes the cors configuration information set for the bucket.
See also: AWS API Documentation
Request Syntax
response = bucket_cors.delete()
Returns a list of all the available sub-resources for this Resource.
Calls S3.Client.get_bucket_cors() to update the attributes of the BucketCors resource. Note that the load and reload methods are the same method and can be used interchangeably.
See also: AWS API Documentation
Request Syntax
bucket_cors.load()
Sets the cors configuration for a bucket.
See also: AWS API Documentation
Request Syntax
response = bucket_cors.put(
CORSConfiguration={
'CORSRules': [
{
'AllowedHeaders': [
'string',
],
'AllowedMethods': [
'string',
],
'AllowedOrigins': [
'string',
],
'ExposeHeaders': [
'string',
],
'MaxAgeSeconds': 123
},
]
},
)
[REQUIRED]
Calls S3.Client.get_bucket_cors() to update the attributes of the BucketCors resource. Note that the load and reload methods are the same method and can be used interchangeably.
See also: AWS API Documentation
Request Syntax
bucket_cors.reload()
Sub-resources
Sub-resources are methods that create a new instance of a child resource. This resource's identifiers get passed along to the child. For more information about sub-resources refer to the Resources Introduction Guide.
A resource representing an Amazon Simple Storage Service (S3) BucketLifecycle:
import boto3
s3 = boto3.resource('s3')
bucket_lifecycle = s3.BucketLifecycle('bucket_name')
These are the resource's available identifiers:
These are the resource's available attributes:
These are the resource's available actions:
These are the resource's available sub-resources:
Identifiers
Identifiers are properties of a resource that are set upon instantation of the resource. For more information about identifiers refer to the Resources Introduction Guide.
(string) The BucketLifecycle's bucket_name identifier. This must be set.
Attributes
Attributes provide access to the properties of a resource. Attributes are lazy-loaded the first time one is accessed via the load() method. For more information about attributes refer to the Resources Introduction Guide.
Actions
Actions call operations on resources. They may automatically handle the passing in of arguments set from identifiers and some attributes. For more information about actions refer to the Resources Introduction Guide.
Deletes the lifecycle configuration from the bucket.
See also: AWS API Documentation
Request Syntax
response = bucket_lifecycle.delete()
Returns a list of all the available sub-resources for this Resource.
Calls S3.Client.get_bucket_lifecycle() to update the attributes of the BucketLifecycle resource. Note that the load and reload methods are the same method and can be used interchangeably.
See also: AWS API Documentation
Request Syntax
bucket_lifecycle.load()
Deprecated, see the PutBucketLifecycleConfiguration operation.
See also: AWS API Documentation
Request Syntax
response = bucket_lifecycle.put(
LifecycleConfiguration={
'Rules': [
{
'Expiration': {
'Date': datetime(2015, 1, 1),
'Days': 123,
'ExpiredObjectDeleteMarker': True|False
},
'ID': 'string',
'Prefix': 'string',
'Status': 'Enabled'|'Disabled',
'Transition': {
'Date': datetime(2015, 1, 1),
'Days': 123,
'StorageClass': 'GLACIER'|'STANDARD_IA'
},
'NoncurrentVersionTransition': {
'NoncurrentDays': 123,
'StorageClass': 'GLACIER'|'STANDARD_IA'
},
'NoncurrentVersionExpiration': {
'NoncurrentDays': 123
},
'AbortIncompleteMultipartUpload': {
'DaysAfterInitiation': 123
}
},
]
}
)
Calls S3.Client.get_bucket_lifecycle() to update the attributes of the BucketLifecycle resource. Note that the load and reload methods are the same method and can be used interchangeably.
See also: AWS API Documentation
Request Syntax
bucket_lifecycle.reload()
Sub-resources
Sub-resources are methods that create a new instance of a child resource. This resource's identifiers get passed along to the child. For more information about sub-resources refer to the Resources Introduction Guide.
A resource representing an Amazon Simple Storage Service (S3) BucketLogging:
import boto3
s3 = boto3.resource('s3')
bucket_logging = s3.BucketLogging('bucket_name')
These are the resource's available identifiers:
These are the resource's available attributes:
These are the resource's available actions:
These are the resource's available sub-resources:
Identifiers
Identifiers are properties of a resource that are set upon instantation of the resource. For more information about identifiers refer to the Resources Introduction Guide.
(string) The BucketLogging's bucket_name identifier. This must be set.
Attributes
Attributes provide access to the properties of a resource. Attributes are lazy-loaded the first time one is accessed via the load() method. For more information about attributes refer to the Resources Introduction Guide.
Actions
Actions call operations on resources. They may automatically handle the passing in of arguments set from identifiers and some attributes. For more information about actions refer to the Resources Introduction Guide.
Returns a list of all the available sub-resources for this Resource.
Calls S3.Client.get_bucket_logging() to update the attributes of the BucketLogging resource. Note that the load and reload methods are the same method and can be used interchangeably.
See also: AWS API Documentation
Request Syntax
bucket_logging.load()
Set the logging parameters for a bucket and to specify permissions for who can view and modify the logging parameters. To set the logging status of a bucket, you must be the bucket owner.
See also: AWS API Documentation
Request Syntax
response = bucket_logging.put(
BucketLoggingStatus={
'LoggingEnabled': {
'TargetBucket': 'string',
'TargetGrants': [
{
'Grantee': {
'DisplayName': 'string',
'EmailAddress': 'string',
'ID': 'string',
'Type': 'CanonicalUser'|'AmazonCustomerByEmail'|'Group',
'URI': 'string'
},
'Permission': 'FULL_CONTROL'|'READ'|'WRITE'
},
],
'TargetPrefix': 'string'
}
},
)
[REQUIRED]
Calls S3.Client.get_bucket_logging() to update the attributes of the BucketLogging resource. Note that the load and reload methods are the same method and can be used interchangeably.
See also: AWS API Documentation
Request Syntax
bucket_logging.reload()
Sub-resources
Sub-resources are methods that create a new instance of a child resource. This resource's identifiers get passed along to the child. For more information about sub-resources refer to the Resources Introduction Guide.
A resource representing an Amazon Simple Storage Service (S3) BucketNotification:
import boto3
s3 = boto3.resource('s3')
bucket_notification = s3.BucketNotification('bucket_name')
These are the resource's available identifiers:
These are the resource's available attributes:
These are the resource's available actions:
These are the resource's available sub-resources:
Identifiers
Identifiers are properties of a resource that are set upon instantation of the resource. For more information about identifiers refer to the Resources Introduction Guide.
(string) The BucketNotification's bucket_name identifier. This must be set.
Attributes
Attributes provide access to the properties of a resource. Attributes are lazy-loaded the first time one is accessed via the load() method. For more information about attributes refer to the Resources Introduction Guide.
Actions
Actions call operations on resources. They may automatically handle the passing in of arguments set from identifiers and some attributes. For more information about actions refer to the Resources Introduction Guide.
Returns a list of all the available sub-resources for this Resource.
Calls S3.Client.get_bucket_notification_configuration() to update the attributes of the BucketNotification resource. Note that the load and reload methods are the same method and can be used interchangeably.
See also: AWS API Documentation
Request Syntax
bucket_notification.load()
Enables notifications of specified events for a bucket.
See also: AWS API Documentation
Request Syntax
response = bucket_notification.put(
NotificationConfiguration={
'TopicConfigurations': [
{
'Id': 'string',
'TopicArn': 'string',
'Events': [
's3:ReducedRedundancyLostObject'|'s3:ObjectCreated:*'|'s3:ObjectCreated:Put'|'s3:ObjectCreated:Post'|'s3:ObjectCreated:Copy'|'s3:ObjectCreated:CompleteMultipartUpload'|'s3:ObjectRemoved:*'|'s3:ObjectRemoved:Delete'|'s3:ObjectRemoved:DeleteMarkerCreated',
],
'Filter': {
'Key': {
'FilterRules': [
{
'Name': 'prefix'|'suffix',
'Value': 'string'
},
]
}
}
},
],
'QueueConfigurations': [
{
'Id': 'string',
'QueueArn': 'string',
'Events': [
's3:ReducedRedundancyLostObject'|'s3:ObjectCreated:*'|'s3:ObjectCreated:Put'|'s3:ObjectCreated:Post'|'s3:ObjectCreated:Copy'|'s3:ObjectCreated:CompleteMultipartUpload'|'s3:ObjectRemoved:*'|'s3:ObjectRemoved:Delete'|'s3:ObjectRemoved:DeleteMarkerCreated',
],
'Filter': {
'Key': {
'FilterRules': [
{
'Name': 'prefix'|'suffix',
'Value': 'string'
},
]
}
}
},
],
'LambdaFunctionConfigurations': [
{
'Id': 'string',
'LambdaFunctionArn': 'string',
'Events': [
's3:ReducedRedundancyLostObject'|'s3:ObjectCreated:*'|'s3:ObjectCreated:Put'|'s3:ObjectCreated:Post'|'s3:ObjectCreated:Copy'|'s3:ObjectCreated:CompleteMultipartUpload'|'s3:ObjectRemoved:*'|'s3:ObjectRemoved:Delete'|'s3:ObjectRemoved:DeleteMarkerCreated',
],
'Filter': {
'Key': {
'FilterRules': [
{
'Name': 'prefix'|'suffix',
'Value': 'string'
},
]
}
}
},
]
}
)
[REQUIRED] Container for specifying the notification configuration of the bucket. If this element is empty, notifications are turned off on the bucket.
Calls S3.Client.get_bucket_notification_configuration() to update the attributes of the BucketNotification resource. Note that the load and reload methods are the same method and can be used interchangeably.
See also: AWS API Documentation
Request Syntax
bucket_notification.reload()
Sub-resources
Sub-resources are methods that create a new instance of a child resource. This resource's identifiers get passed along to the child. For more information about sub-resources refer to the Resources Introduction Guide.
A resource representing an Amazon Simple Storage Service (S3) BucketPolicy:
import boto3
s3 = boto3.resource('s3')
bucket_policy = s3.BucketPolicy('bucket_name')
These are the resource's available identifiers:
These are the resource's available attributes:
These are the resource's available actions:
These are the resource's available sub-resources:
Identifiers
Identifiers are properties of a resource that are set upon instantation of the resource. For more information about identifiers refer to the Resources Introduction Guide.
(string) The BucketPolicy's bucket_name identifier. This must be set.
Attributes
Attributes provide access to the properties of a resource. Attributes are lazy-loaded the first time one is accessed via the load() method. For more information about attributes refer to the Resources Introduction Guide.
Actions
Actions call operations on resources. They may automatically handle the passing in of arguments set from identifiers and some attributes. For more information about actions refer to the Resources Introduction Guide.
Deletes the policy from the bucket.
See also: AWS API Documentation
Request Syntax
response = bucket_policy.delete()
Returns a list of all the available sub-resources for this Resource.
Calls S3.Client.get_bucket_policy() to update the attributes of the BucketPolicy resource. Note that the load and reload methods are the same method and can be used interchangeably.
See also: AWS API Documentation
Request Syntax
bucket_policy.load()
Replaces a policy on a bucket. If the bucket already has a policy, the one in this request completely replaces it.
See also: AWS API Documentation
Request Syntax
response = bucket_policy.put(
Policy='string'
)
Calls S3.Client.get_bucket_policy() to update the attributes of the BucketPolicy resource. Note that the load and reload methods are the same method and can be used interchangeably.
See also: AWS API Documentation
Request Syntax
bucket_policy.reload()
Sub-resources
Sub-resources are methods that create a new instance of a child resource. This resource's identifiers get passed along to the child. For more information about sub-resources refer to the Resources Introduction Guide.
A resource representing an Amazon Simple Storage Service (S3) BucketRequestPayment:
import boto3
s3 = boto3.resource('s3')
bucket_request_payment = s3.BucketRequestPayment('bucket_name')
These are the resource's available identifiers:
These are the resource's available attributes:
These are the resource's available actions:
These are the resource's available sub-resources:
Identifiers
Identifiers are properties of a resource that are set upon instantation of the resource. For more information about identifiers refer to the Resources Introduction Guide.
(string) The BucketRequestPayment's bucket_name identifier. This must be set.
Attributes
Attributes provide access to the properties of a resource. Attributes are lazy-loaded the first time one is accessed via the load() method. For more information about attributes refer to the Resources Introduction Guide.
Actions
Actions call operations on resources. They may automatically handle the passing in of arguments set from identifiers and some attributes. For more information about actions refer to the Resources Introduction Guide.
Returns a list of all the available sub-resources for this Resource.
Calls S3.Client.get_bucket_request_payment() to update the attributes of the BucketRequestPayment resource. Note that the load and reload methods are the same method and can be used interchangeably.
See also: AWS API Documentation
Request Syntax
bucket_request_payment.load()
Sets the request payment configuration for a bucket. By default, the bucket owner pays for downloads from the bucket. This configuration parameter enables the bucket owner (only) to specify that the person requesting the download will be charged for the download. Documentation on requester pays buckets can be found at http://docs.aws.amazon.com/AmazonS3/latest/dev/RequesterPaysBuckets.html
See also: AWS API Documentation
Request Syntax
response = bucket_request_payment.put(
RequestPaymentConfiguration={
'Payer': 'Requester'|'BucketOwner'
}
)
[REQUIRED]
Calls S3.Client.get_bucket_request_payment() to update the attributes of the BucketRequestPayment resource. Note that the load and reload methods are the same method and can be used interchangeably.
See also: AWS API Documentation
Request Syntax
bucket_request_payment.reload()
Sub-resources
Sub-resources are methods that create a new instance of a child resource. This resource's identifiers get passed along to the child. For more information about sub-resources refer to the Resources Introduction Guide.
A resource representing an Amazon Simple Storage Service (S3) BucketTagging:
import boto3
s3 = boto3.resource('s3')
bucket_tagging = s3.BucketTagging('bucket_name')
These are the resource's available identifiers:
These are the resource's available attributes:
These are the resource's available actions:
These are the resource's available sub-resources:
Identifiers
Identifiers are properties of a resource that are set upon instantation of the resource. For more information about identifiers refer to the Resources Introduction Guide.
(string) The BucketTagging's bucket_name identifier. This must be set.
Attributes
Attributes provide access to the properties of a resource. Attributes are lazy-loaded the first time one is accessed via the load() method. For more information about attributes refer to the Resources Introduction Guide.
Actions
Actions call operations on resources. They may automatically handle the passing in of arguments set from identifiers and some attributes. For more information about actions refer to the Resources Introduction Guide.
Deletes the tags from the bucket.
See also: AWS API Documentation
Request Syntax
response = bucket_tagging.delete()
Returns a list of all the available sub-resources for this Resource.
Calls S3.Client.get_bucket_tagging() to update the attributes of the BucketTagging resource. Note that the load and reload methods are the same method and can be used interchangeably.
See also: AWS API Documentation
Request Syntax
bucket_tagging.load()
Sets the tags for a bucket.
See also: AWS API Documentation
Request Syntax
response = bucket_tagging.put(
Tagging={
'TagSet': [
{
'Key': 'string',
'Value': 'string'
},
]
}
)
[REQUIRED]
Calls S3.Client.get_bucket_tagging() to update the attributes of the BucketTagging resource. Note that the load and reload methods are the same method and can be used interchangeably.
See also: AWS API Documentation
Request Syntax
bucket_tagging.reload()
Sub-resources
Sub-resources are methods that create a new instance of a child resource. This resource's identifiers get passed along to the child. For more information about sub-resources refer to the Resources Introduction Guide.
A resource representing an Amazon Simple Storage Service (S3) BucketVersioning:
import boto3
s3 = boto3.resource('s3')
bucket_versioning = s3.BucketVersioning('bucket_name')
These are the resource's available identifiers:
These are the resource's available attributes:
These are the resource's available actions:
These are the resource's available sub-resources:
Identifiers
Identifiers are properties of a resource that are set upon instantation of the resource. For more information about identifiers refer to the Resources Introduction Guide.
(string) The BucketVersioning's bucket_name identifier. This must be set.
Attributes
Attributes provide access to the properties of a resource. Attributes are lazy-loaded the first time one is accessed via the load() method. For more information about attributes refer to the Resources Introduction Guide.
Actions
Actions call operations on resources. They may automatically handle the passing in of arguments set from identifiers and some attributes. For more information about actions refer to the Resources Introduction Guide.
Sets the versioning state of an existing bucket. To set the versioning state, you must be the bucket owner.
See also: AWS API Documentation
Request Syntax
response = bucket_versioning.enable(
MFA='string',
)
Returns a list of all the available sub-resources for this Resource.
Calls S3.Client.get_bucket_versioning() to update the attributes of the BucketVersioning resource. Note that the load and reload methods are the same method and can be used interchangeably.
See also: AWS API Documentation
Request Syntax
bucket_versioning.load()
Sets the versioning state of an existing bucket. To set the versioning state, you must be the bucket owner.
See also: AWS API Documentation
Request Syntax
response = bucket_versioning.put(
MFA='string',
VersioningConfiguration={
'MFADelete': 'Enabled'|'Disabled',
'Status': 'Enabled'|'Suspended'
}
)
[REQUIRED]
None
Calls S3.Client.get_bucket_versioning() to update the attributes of the BucketVersioning resource. Note that the load and reload methods are the same method and can be used interchangeably.
See also: AWS API Documentation
Request Syntax
bucket_versioning.reload()
Sets the versioning state of an existing bucket. To set the versioning state, you must be the bucket owner.
See also: AWS API Documentation
Request Syntax
response = bucket_versioning.suspend(
MFA='string',
)
Sub-resources
Sub-resources are methods that create a new instance of a child resource. This resource's identifiers get passed along to the child. For more information about sub-resources refer to the Resources Introduction Guide.
A resource representing an Amazon Simple Storage Service (S3) BucketWebsite:
import boto3
s3 = boto3.resource('s3')
bucket_website = s3.BucketWebsite('bucket_name')
These are the resource's available identifiers:
These are the resource's available attributes:
These are the resource's available actions:
These are the resource's available sub-resources:
Identifiers
Identifiers are properties of a resource that are set upon instantation of the resource. For more information about identifiers refer to the Resources Introduction Guide.
(string) The BucketWebsite's bucket_name identifier. This must be set.
Attributes
Attributes provide access to the properties of a resource. Attributes are lazy-loaded the first time one is accessed via the load() method. For more information about attributes refer to the Resources Introduction Guide.
Actions
Actions call operations on resources. They may automatically handle the passing in of arguments set from identifiers and some attributes. For more information about actions refer to the Resources Introduction Guide.
This operation removes the website configuration from the bucket.
See also: AWS API Documentation
Request Syntax
response = bucket_website.delete()
Returns a list of all the available sub-resources for this Resource.
Calls S3.Client.get_bucket_website() to update the attributes of the BucketWebsite resource. Note that the load and reload methods are the same method and can be used interchangeably.
See also: AWS API Documentation
Request Syntax
bucket_website.load()
Set the website configuration for a bucket.
See also: AWS API Documentation
Request Syntax
response = bucket_website.put(
WebsiteConfiguration={
'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'
}
},
]
}
)
[REQUIRED]
Calls S3.Client.get_bucket_website() to update the attributes of the BucketWebsite resource. Note that the load and reload methods are the same method and can be used interchangeably.
See also: AWS API Documentation
Request Syntax
bucket_website.reload()
Sub-resources
Sub-resources are methods that create a new instance of a child resource. This resource's identifiers get passed along to the child. For more information about sub-resources refer to the Resources Introduction Guide.
A resource representing an Amazon Simple Storage Service (S3) MultipartUpload:
import boto3
s3 = boto3.resource('s3')
multipart_upload = s3.MultipartUpload('bucket_name','object_key','id')
These are the resource's available identifiers:
These are the resource's available attributes:
These are the resource's available actions:
These are the resource's available sub-resources:
These are the resource's available collections:
Identifiers
Identifiers are properties of a resource that are set upon instantation of the resource. For more information about identifiers refer to the Resources Introduction Guide.
(string) The MultipartUpload's bucket_name identifier. This must be set.
(string) The MultipartUpload's object_key identifier. This must be set.
(string) The MultipartUpload's id identifier. This must be set.
Attributes
Attributes provide access to the properties of a resource. Attributes are lazy-loaded the first time one is accessed via the load() method. For more information about attributes refer to the Resources Introduction Guide.
Actions
Actions call operations on resources. They may automatically handle the passing in of arguments set from identifiers and some attributes. For more information about actions refer to the Resources Introduction Guide.
Aborts a multipart upload.
To verify that all parts have been removed, so you don't get charged for the part storage, you should call the List Parts operation and ensure the parts list is empty.
See also: AWS API Documentation
Request Syntax
response = multipart_upload.abort(
RequestPayer='requester'
)
{
'RequestCharged': 'requester'
}
Response Structure
Completes a multipart upload by assembling previously uploaded parts.
See also: AWS API Documentation
Request Syntax
object = multipart_upload.complete(
MultipartUpload={
'Parts': [
{
'ETag': 'string',
'PartNumber': 123
},
]
},
RequestPayer='requester'
)
s3.Object
Object resource
Returns a list of all the available sub-resources for this Resource.
Sub-resources
Sub-resources are methods that create a new instance of a child resource. This resource's identifiers get passed along to the child. For more information about sub-resources refer to the Resources Introduction Guide.
Creates a Object resource.:
object = multipart_upload.Object()
Creates a MultipartUploadPart resource.:
multipart_upload_part = multipart_upload.Part('part_number')
Collections
Collections provide an interface to iterate over and manipulate groups of resources. For more information about collections refer to the Resources Introduction Guide.
A collection of MultipartUploadPart resources
Creates an iterable of all MultipartUploadPart resources in the collection.
See also: AWS API Documentation
Request Syntax
multipart_upload_part_iterator = multipart_upload.parts.all()
Creates an iterable of all MultipartUploadPart resources in the collection filtered by kwargs passed to method.
See also: AWS API Documentation
Request Syntax
multipart_upload_part_iterator = multipart_upload.parts.filter(
MaxParts=123,
PartNumberMarker=123,
RequestPayer='requester'
)
list(s3.MultipartUploadPart)
A list of MultipartUploadPart resources
Creates an iterable up to a specified amount of MultipartUploadPart resources in the collection.
See also: AWS API Documentation
Request Syntax
multipart_upload_part_iterator = multipart_upload.parts.limit(
count=123
)
Creates an iterable of all MultipartUploadPart resources in the collection, but limits the number of items returned by each service call by the specified amount.
See also: AWS API Documentation
Request Syntax
multipart_upload_part_iterator = multipart_upload.parts.page_size(
count=123
)
A resource representing an Amazon Simple Storage Service (S3) MultipartUploadPart:
import boto3
s3 = boto3.resource('s3')
multipart_upload_part = s3.MultipartUploadPart('bucket_name','object_key','multipart_upload_id','part_number')
These are the resource's available identifiers:
These are the resource's available attributes:
These are the resource's available actions:
These are the resource's available sub-resources:
Identifiers
Identifiers are properties of a resource that are set upon instantation of the resource. For more information about identifiers refer to the Resources Introduction Guide.
(string) The MultipartUploadPart's bucket_name identifier. This must be set.
(string) The MultipartUploadPart's object_key identifier. This must be set.
(string) The MultipartUploadPart's multipart_upload_id identifier. This must be set.
(string) The MultipartUploadPart's part_number identifier. This must be set.
Attributes
Attributes provide access to the properties of a resource. Attributes are lazy-loaded the first time one is accessed via the load() method. For more information about attributes refer to the Resources Introduction Guide.
Actions
Actions call operations on resources. They may automatically handle the passing in of arguments set from identifiers and some attributes. For more information about actions refer to the Resources Introduction Guide.
Uploads a part by copying data from an existing object as data source.
See also: AWS API Documentation
Request Syntax
response = multipart_upload_part.copy_from(
CopySource='string' or {'Bucket': 'string', 'Key': 'string', 'VersionId': 'string'},
CopySourceIfMatch='string',
CopySourceIfModifiedSince=datetime(2015, 1, 1),
CopySourceIfNoneMatch='string',
CopySourceIfUnmodifiedSince=datetime(2015, 1, 1),
CopySourceRange='string',
SSECustomerAlgorithm='string',
SSECustomerKey='string',
CopySourceSSECustomerAlgorithm='string',
CopySourceSSECustomerKey='string',
RequestPayer='requester'
)
dict
Response Syntax
{
'CopySourceVersionId': 'string',
'CopyPartResult': {
'ETag': 'string',
'LastModified': datetime(2015, 1, 1)
},
'ServerSideEncryption': 'AES256'|'aws:kms',
'SSECustomerAlgorithm': 'string',
'SSECustomerKeyMD5': 'string',
'SSEKMSKeyId': 'string',
'RequestCharged': 'requester'
}
Response Structure
Returns a list of all the available sub-resources for this Resource.
Uploads a part in a multipart upload.
Note: After you initiate multipart upload and upload one or more parts, you must either complete or abort multipart upload in order to stop getting charged for storage of the uploaded parts. Only after you either complete or abort multipart upload, Amazon S3 frees up the parts storage and stops charging you for the parts storage.
See also: AWS API Documentation
Request Syntax
response = multipart_upload_part.upload(
Body=b'bytes'|file,
ContentLength=123,
ContentMD5='string',
SSECustomerAlgorithm='string',
SSECustomerKey='string',
RequestPayer='requester'
)
dict
Response Syntax
{
'ServerSideEncryption': 'AES256'|'aws:kms',
'ETag': 'string',
'SSECustomerAlgorithm': 'string',
'SSECustomerKeyMD5': 'string',
'SSEKMSKeyId': 'string',
'RequestCharged': 'requester'
}
Response Structure
Sub-resources
Sub-resources are methods that create a new instance of a child resource. This resource's identifiers get passed along to the child. For more information about sub-resources refer to the Resources Introduction Guide.
Creates a MultipartUpload resource.:
multipart_upload = multipart_upload_part.MultipartUpload()
A resource representing an Amazon Simple Storage Service (S3) Object:
import boto3
s3 = boto3.resource('s3')
object = s3.Object('bucket_name','key')
These are the resource's available identifiers:
These are the resource's available attributes:
These are the resource's available actions:
These are the resource's available sub-resources:
These are the resource's available waiters:
Identifiers
Identifiers are properties of a resource that are set upon instantation of the resource. For more information about identifiers refer to the Resources Introduction Guide.
(string) The Object's bucket_name identifier. This must be set.
(string) The Object's key identifier. This must be set.
Attributes
Attributes provide access to the properties of a resource. Attributes are lazy-loaded the first time one is accessed via the load() method. For more information about attributes refer to the Resources Introduction Guide.
Actions
Actions call operations on resources. They may automatically handle the passing in of arguments set from identifiers and some attributes. For more information about actions refer to the Resources Introduction Guide.
Copy an object from one S3 location to this object.
This is a managed transfer which will perform a multipart copy in multiple threads if necessary.
Usage:
import boto3
s3 = boto3.resource('s3')
copy_source = {
'Bucket': 'mybucket',
'Key': 'mykey'
}
bucket = s3.Bucket('otherbucket')
obj = bucket.Object('otherkey')
obj.copy(copy_source)
Creates a copy of an object that is already stored in Amazon S3.
See also: AWS API Documentation
Request Syntax
response = object.copy_from(
ACL='private'|'public-read'|'public-read-write'|'authenticated-read'|'aws-exec-read'|'bucket-owner-read'|'bucket-owner-full-control',
CacheControl='string',
ContentDisposition='string',
ContentEncoding='string',
ContentLanguage='string',
ContentType='string',
CopySource='string' or {'Bucket': 'string', 'Key': 'string', 'VersionId': 'string'},
CopySourceIfMatch='string',
CopySourceIfModifiedSince=datetime(2015, 1, 1),
CopySourceIfNoneMatch='string',
CopySourceIfUnmodifiedSince=datetime(2015, 1, 1),
Expires=datetime(2015, 1, 1),
GrantFullControl='string',
GrantRead='string',
GrantReadACP='string',
GrantWriteACP='string',
Metadata={
'string': 'string'
},
MetadataDirective='COPY'|'REPLACE',
TaggingDirective='COPY'|'REPLACE',
ServerSideEncryption='AES256'|'aws:kms',
StorageClass='STANDARD'|'REDUCED_REDUNDANCY'|'STANDARD_IA',
WebsiteRedirectLocation='string',
SSECustomerAlgorithm='string',
SSECustomerKey='string',
SSEKMSKeyId='string',
CopySourceSSECustomerAlgorithm='string',
CopySourceSSECustomerKey='string',
RequestPayer='requester',
Tagging='string'
)
A map of metadata to store with the object in S3.
dict
Response Syntax
{
'CopyObjectResult': {
'ETag': 'string',
'LastModified': datetime(2015, 1, 1)
},
'Expiration': 'string',
'CopySourceVersionId': 'string',
'VersionId': 'string',
'ServerSideEncryption': 'AES256'|'aws:kms',
'SSECustomerAlgorithm': 'string',
'SSECustomerKeyMD5': 'string',
'SSEKMSKeyId': 'string',
'RequestCharged': 'requester'
}
Response Structure
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.
See also: AWS API Documentation
Request Syntax
response = object.delete(
MFA='string',
VersionId='string',
RequestPayer='requester'
)
dict
Response Syntax
{
'DeleteMarker': True|False,
'VersionId': 'string',
'RequestCharged': 'requester'
}
Response Structure
Download an S3 object to a file.
Usage:
import boto3
s3 = boto3.resource('s3')
s3.Object('mybucket', 'hello.txt').download_file('/tmp/hello.txt')
Similar behavior as S3Transfer's download_file() method, except that parameters are capitalized. Detailed examples can be found at S3Transfer's Usage.
Download this object from S3 to a file-like object.
The file-like object must be in binary mode.
This is a managed transfer which will perform a multipart download in multiple threads if necessary.
Usage:
import boto3
s3 = boto3.resource('s3')
bucket = s3.Bucket('mybucket')
obj = bucket.Object('mykey')
with open('filename', 'wb') as data:
obj.download_fileobj(data)
Retrieves objects from Amazon S3.
See also: AWS API Documentation
Request Syntax
response = object.get(
IfMatch='string',
IfModifiedSince=datetime(2015, 1, 1),
IfNoneMatch='string',
IfUnmodifiedSince=datetime(2015, 1, 1),
Range='string',
ResponseCacheControl='string',
ResponseContentDisposition='string',
ResponseContentEncoding='string',
ResponseContentLanguage='string',
ResponseContentType='string',
ResponseExpires=datetime(2015, 1, 1),
VersionId='string',
SSECustomerAlgorithm='string',
SSECustomerKey='string',
RequestPayer='requester',
PartNumber=123
)
dict
Response Syntax
{
'Body': StreamingBody(),
'DeleteMarker': True|False,
'AcceptRanges': 'string',
'Expiration': 'string',
'Restore': 'string',
'LastModified': datetime(2015, 1, 1),
'ContentLength': 123,
'ETag': 'string',
'MissingMeta': 123,
'VersionId': 'string',
'CacheControl': 'string',
'ContentDisposition': 'string',
'ContentEncoding': 'string',
'ContentLanguage': 'string',
'ContentRange': 'string',
'ContentType': 'string',
'Expires': datetime(2015, 1, 1),
'WebsiteRedirectLocation': 'string',
'ServerSideEncryption': 'AES256'|'aws:kms',
'Metadata': {
'string': 'string'
},
'SSECustomerAlgorithm': 'string',
'SSECustomerKeyMD5': 'string',
'SSEKMSKeyId': 'string',
'StorageClass': 'STANDARD'|'REDUCED_REDUNDANCY'|'STANDARD_IA',
'RequestCharged': 'requester',
'ReplicationStatus': 'COMPLETE'|'PENDING'|'FAILED'|'REPLICA',
'PartsCount': 123,
'TagCount': 123
}
Response Structure
Returns a list of all the available sub-resources for this Resource.
Initiates a multipart upload and returns an upload ID.
Note: After you initiate multipart upload and upload one or more parts, you must either complete or abort multipart upload in order to stop getting charged for storage of the uploaded parts. Only after you either complete or abort multipart upload, Amazon S3 frees up the parts storage and stops charging you for the parts storage.
See also: AWS API Documentation
Request Syntax
multipart_upload = object.initiate_multipart_upload(
ACL='private'|'public-read'|'public-read-write'|'authenticated-read'|'aws-exec-read'|'bucket-owner-read'|'bucket-owner-full-control',
CacheControl='string',
ContentDisposition='string',
ContentEncoding='string',
ContentLanguage='string',
ContentType='string',
Expires=datetime(2015, 1, 1),
GrantFullControl='string',
GrantRead='string',
GrantReadACP='string',
GrantWriteACP='string',
Metadata={
'string': 'string'
},
ServerSideEncryption='AES256'|'aws:kms',
StorageClass='STANDARD'|'REDUCED_REDUNDANCY'|'STANDARD_IA',
WebsiteRedirectLocation='string',
SSECustomerAlgorithm='string',
SSECustomerKey='string',
SSEKMSKeyId='string',
RequestPayer='requester'
)
A map of metadata to store with the object in S3.
s3.MultipartUpload
MultipartUpload resource
Calls S3.Client.head_object() to update the attributes of the Object resource. Note that the load and reload methods are the same method and can be used interchangeably.
See also: AWS API Documentation
Request Syntax
object.load()
Adds an object to a bucket.
See also: AWS API Documentation
Request Syntax
response = object.put(
ACL='private'|'public-read'|'public-read-write'|'authenticated-read'|'aws-exec-read'|'bucket-owner-read'|'bucket-owner-full-control',
Body=b'bytes'|file,
CacheControl='string',
ContentDisposition='string',
ContentEncoding='string',
ContentLanguage='string',
ContentLength=123,
ContentMD5='string',
ContentType='string',
Expires=datetime(2015, 1, 1),
GrantFullControl='string',
GrantRead='string',
GrantReadACP='string',
GrantWriteACP='string',
Metadata={
'string': 'string'
},
ServerSideEncryption='AES256'|'aws:kms',
StorageClass='STANDARD'|'REDUCED_REDUNDANCY'|'STANDARD_IA',
WebsiteRedirectLocation='string',
SSECustomerAlgorithm='string',
SSECustomerKey='string',
SSEKMSKeyId='string',
RequestPayer='requester',
Tagging='string'
)
A map of metadata to store with the object in S3.
dict
Response Syntax
{
'Expiration': 'string',
'ETag': 'string',
'ServerSideEncryption': 'AES256'|'aws:kms',
'VersionId': 'string',
'SSECustomerAlgorithm': 'string',
'SSECustomerKeyMD5': 'string',
'SSEKMSKeyId': 'string',
'RequestCharged': 'requester'
}
Response Structure
Calls S3.Client.head_object() to update the attributes of the Object resource. Note that the load and reload methods are the same method and can be used interchangeably.
See also: AWS API Documentation
Request Syntax
object.reload()
Restores an archived copy of an object back into Amazon S3
See also: AWS API Documentation
Request Syntax
response = object.restore_object(
VersionId='string',
RestoreRequest={
'Days': 123,
'GlacierJobParameters': {
'Tier': 'Standard'|'Bulk'|'Expedited'
}
},
RequestPayer='requester'
)
dict
Response Syntax
{
'RequestCharged': 'requester'
}
Response Structure
Upload a file to an S3 object.
Usage:
import boto3
s3 = boto3.resource('s3')
s3.Object('mybucket', 'hello.txt').upload_file('/tmp/hello.txt')
Similar behavior as S3Transfer's upload_file() method, except that parameters are capitalized. Detailed examples can be found at S3Transfer's Usage.
Upload a file-like object to this object.
The file-like object must be in binary mode.
This is a managed transfer which will perform a multipart upload in multiple threads if necessary.
Usage:
import boto3
s3 = boto3.resource('s3')
bucket = s3.Bucket('mybucket')
obj = bucket.Object('mykey')
with open('filename', 'rb') as data:
obj.upload_fileobj(data)
Sub-resources
Sub-resources are methods that create a new instance of a child resource. This resource's identifiers get passed along to the child. For more information about sub-resources refer to the Resources Introduction Guide.
Creates a ObjectAcl resource.:
object_acl = object.Acl()
Creates a Bucket resource.:
bucket = object.Bucket()
Creates a MultipartUpload resource.:
multipart_upload = object.MultipartUpload('id')
Creates a ObjectVersion resource.:
object_version = object.Version('id')
Waiters
Waiters provide an interface to wait for a resource to reach a specific state. For more information about waiters refer to the Resources Introduction Guide.
Waits until this Object is exists. This method calls S3.Waiter.object_exists.wait() which polls. S3.Client.head_object() every 5 seconds until a successful state is reached. An error is returned after 20 failed checks.
See also: AWS API Documentation
Request Syntax
object.wait_until_exists(
IfMatch='string',
IfModifiedSince=datetime(2015, 1, 1),
IfNoneMatch='string',
IfUnmodifiedSince=datetime(2015, 1, 1),
Range='string',
VersionId='string',
SSECustomerAlgorithm='string',
SSECustomerKey='string',
RequestPayer='requester',
PartNumber=123
)
None
Waits until this Object is not exists. This method calls S3.Waiter.object_not_exists.wait() which polls. S3.Client.head_object() every 5 seconds until a successful state is reached. An error is returned after 20 failed checks.
See also: AWS API Documentation
Request Syntax
object.wait_until_not_exists(
IfMatch='string',
IfModifiedSince=datetime(2015, 1, 1),
IfNoneMatch='string',
IfUnmodifiedSince=datetime(2015, 1, 1),
Range='string',
VersionId='string',
SSECustomerAlgorithm='string',
SSECustomerKey='string',
RequestPayer='requester',
PartNumber=123
)
None
A resource representing an Amazon Simple Storage Service (S3) ObjectAcl:
import boto3
s3 = boto3.resource('s3')
object_acl = s3.ObjectAcl('bucket_name','object_key')
These are the resource's available identifiers:
These are the resource's available attributes:
These are the resource's available actions:
These are the resource's available sub-resources:
Identifiers
Identifiers are properties of a resource that are set upon instantation of the resource. For more information about identifiers refer to the Resources Introduction Guide.
(string) The ObjectAcl's bucket_name identifier. This must be set.
(string) The ObjectAcl's object_key identifier. This must be set.
Attributes
Attributes provide access to the properties of a resource. Attributes are lazy-loaded the first time one is accessed via the load() method. For more information about attributes refer to the Resources Introduction Guide.
Actions
Actions call operations on resources. They may automatically handle the passing in of arguments set from identifiers and some attributes. For more information about actions refer to the Resources Introduction Guide.
Returns a list of all the available sub-resources for this Resource.
Calls S3.Client.get_object_acl() to update the attributes of the ObjectAcl resource. Note that the load and reload methods are the same method and can be used interchangeably.
See also: AWS API Documentation
Request Syntax
object_acl.load()
uses the acl subresource to set the access control list (ACL) permissions for an object that already exists in a bucket
See also: AWS API Documentation
Request Syntax
response = object_acl.put(
ACL='private'|'public-read'|'public-read-write'|'authenticated-read'|'aws-exec-read'|'bucket-owner-read'|'bucket-owner-full-control',
AccessControlPolicy={
'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'
}
},
GrantFullControl='string',
GrantRead='string',
GrantReadACP='string',
GrantWrite='string',
GrantWriteACP='string',
RequestPayer='requester',
VersionId='string'
)
dict
Response Syntax
{
'RequestCharged': 'requester'
}
Response Structure
Calls S3.Client.get_object_acl() to update the attributes of the ObjectAcl resource. Note that the load and reload methods are the same method and can be used interchangeably.
See also: AWS API Documentation
Request Syntax
object_acl.reload()
Sub-resources
Sub-resources are methods that create a new instance of a child resource. This resource's identifiers get passed along to the child. For more information about sub-resources refer to the Resources Introduction Guide.
A resource representing an Amazon Simple Storage Service (S3) ObjectSummary:
import boto3
s3 = boto3.resource('s3')
object_summary = s3.ObjectSummary('bucket_name','key')
These are the resource's available identifiers:
These are the resource's available attributes:
These are the resource's available actions:
These are the resource's available sub-resources:
These are the resource's available waiters:
Identifiers
Identifiers are properties of a resource that are set upon instantation of the resource. For more information about identifiers refer to the Resources Introduction Guide.
(string) The ObjectSummary's bucket_name identifier. This must be set.
(string) The ObjectSummary's key identifier. This must be set.
Attributes
Attributes provide access to the properties of a resource. Attributes are lazy-loaded the first time one is accessed via the load() method. For more information about attributes refer to the Resources Introduction Guide.
Actions
Actions call operations on resources. They may automatically handle the passing in of arguments set from identifiers and some attributes. For more information about actions refer to the Resources Introduction Guide.
Creates a copy of an object that is already stored in Amazon S3.
See also: AWS API Documentation
Request Syntax
response = object_summary.copy_from(
ACL='private'|'public-read'|'public-read-write'|'authenticated-read'|'aws-exec-read'|'bucket-owner-read'|'bucket-owner-full-control',
CacheControl='string',
ContentDisposition='string',
ContentEncoding='string',
ContentLanguage='string',
ContentType='string',
CopySource='string' or {'Bucket': 'string', 'Key': 'string', 'VersionId': 'string'},
CopySourceIfMatch='string',
CopySourceIfModifiedSince=datetime(2015, 1, 1),
CopySourceIfNoneMatch='string',
CopySourceIfUnmodifiedSince=datetime(2015, 1, 1),
Expires=datetime(2015, 1, 1),
GrantFullControl='string',
GrantRead='string',
GrantReadACP='string',
GrantWriteACP='string',
Metadata={
'string': 'string'
},
MetadataDirective='COPY'|'REPLACE',
TaggingDirective='COPY'|'REPLACE',
ServerSideEncryption='AES256'|'aws:kms',
StorageClass='STANDARD'|'REDUCED_REDUNDANCY'|'STANDARD_IA',
WebsiteRedirectLocation='string',
SSECustomerAlgorithm='string',
SSECustomerKey='string',
SSEKMSKeyId='string',
CopySourceSSECustomerAlgorithm='string',
CopySourceSSECustomerKey='string',
RequestPayer='requester',
Tagging='string'
)
A map of metadata to store with the object in S3.
dict
Response Syntax
{
'CopyObjectResult': {
'ETag': 'string',
'LastModified': datetime(2015, 1, 1)
},
'Expiration': 'string',
'CopySourceVersionId': 'string',
'VersionId': 'string',
'ServerSideEncryption': 'AES256'|'aws:kms',
'SSECustomerAlgorithm': 'string',
'SSECustomerKeyMD5': 'string',
'SSEKMSKeyId': 'string',
'RequestCharged': 'requester'
}
Response Structure
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.
See also: AWS API Documentation
Request Syntax
response = object_summary.delete(
MFA='string',
VersionId='string',
RequestPayer='requester'
)
dict
Response Syntax
{
'DeleteMarker': True|False,
'VersionId': 'string',
'RequestCharged': 'requester'
}
Response Structure
Retrieves objects from Amazon S3.
See also: AWS API Documentation
Request Syntax
response = object_summary.get(
IfMatch='string',
IfModifiedSince=datetime(2015, 1, 1),
IfNoneMatch='string',
IfUnmodifiedSince=datetime(2015, 1, 1),
Range='string',
ResponseCacheControl='string',
ResponseContentDisposition='string',
ResponseContentEncoding='string',
ResponseContentLanguage='string',
ResponseContentType='string',
ResponseExpires=datetime(2015, 1, 1),
VersionId='string',
SSECustomerAlgorithm='string',
SSECustomerKey='string',
RequestPayer='requester',
PartNumber=123
)
dict
Response Syntax
{
'Body': StreamingBody(),
'DeleteMarker': True|False,
'AcceptRanges': 'string',
'Expiration': 'string',
'Restore': 'string',
'LastModified': datetime(2015, 1, 1),
'ContentLength': 123,
'ETag': 'string',
'MissingMeta': 123,
'VersionId': 'string',
'CacheControl': 'string',
'ContentDisposition': 'string',
'ContentEncoding': 'string',
'ContentLanguage': 'string',
'ContentRange': 'string',
'ContentType': 'string',
'Expires': datetime(2015, 1, 1),
'WebsiteRedirectLocation': 'string',
'ServerSideEncryption': 'AES256'|'aws:kms',
'Metadata': {
'string': 'string'
},
'SSECustomerAlgorithm': 'string',
'SSECustomerKeyMD5': 'string',
'SSEKMSKeyId': 'string',
'StorageClass': 'STANDARD'|'REDUCED_REDUNDANCY'|'STANDARD_IA',
'RequestCharged': 'requester',
'ReplicationStatus': 'COMPLETE'|'PENDING'|'FAILED'|'REPLICA',
'PartsCount': 123,
'TagCount': 123
}
Response Structure
Returns a list of all the available sub-resources for this Resource.
Initiates a multipart upload and returns an upload ID.
Note: After you initiate multipart upload and upload one or more parts, you must either complete or abort multipart upload in order to stop getting charged for storage of the uploaded parts. Only after you either complete or abort multipart upload, Amazon S3 frees up the parts storage and stops charging you for the parts storage.
See also: AWS API Documentation
Request Syntax
multipart_upload = object_summary.initiate_multipart_upload(
ACL='private'|'public-read'|'public-read-write'|'authenticated-read'|'aws-exec-read'|'bucket-owner-read'|'bucket-owner-full-control',
CacheControl='string',
ContentDisposition='string',
ContentEncoding='string',
ContentLanguage='string',
ContentType='string',
Expires=datetime(2015, 1, 1),
GrantFullControl='string',
GrantRead='string',
GrantReadACP='string',
GrantWriteACP='string',
Metadata={
'string': 'string'
},
ServerSideEncryption='AES256'|'aws:kms',
StorageClass='STANDARD'|'REDUCED_REDUNDANCY'|'STANDARD_IA',
WebsiteRedirectLocation='string',
SSECustomerAlgorithm='string',
SSECustomerKey='string',
SSEKMSKeyId='string',
RequestPayer='requester'
)
A map of metadata to store with the object in S3.
s3.MultipartUpload
MultipartUpload resource
Calls s3.Client.head_object to update the attributes of the ObjectSummary resource.
Adds an object to a bucket.
See also: AWS API Documentation
Request Syntax
response = object_summary.put(
ACL='private'|'public-read'|'public-read-write'|'authenticated-read'|'aws-exec-read'|'bucket-owner-read'|'bucket-owner-full-control',
Body=b'bytes'|file,
CacheControl='string',
ContentDisposition='string',
ContentEncoding='string',
ContentLanguage='string',
ContentLength=123,
ContentMD5='string',
ContentType='string',
Expires=datetime(2015, 1, 1),
GrantFullControl='string',
GrantRead='string',
GrantReadACP='string',
GrantWriteACP='string',
Metadata={
'string': 'string'
},
ServerSideEncryption='AES256'|'aws:kms',
StorageClass='STANDARD'|'REDUCED_REDUNDANCY'|'STANDARD_IA',
WebsiteRedirectLocation='string',
SSECustomerAlgorithm='string',
SSECustomerKey='string',
SSEKMSKeyId='string',
RequestPayer='requester',
Tagging='string'
)
A map of metadata to store with the object in S3.
dict
Response Syntax
{
'Expiration': 'string',
'ETag': 'string',
'ServerSideEncryption': 'AES256'|'aws:kms',
'VersionId': 'string',
'SSECustomerAlgorithm': 'string',
'SSECustomerKeyMD5': 'string',
'SSEKMSKeyId': 'string',
'RequestCharged': 'requester'
}
Response Structure
Restores an archived copy of an object back into Amazon S3
See also: AWS API Documentation
Request Syntax
response = object_summary.restore_object(
VersionId='string',
RestoreRequest={
'Days': 123,
'GlacierJobParameters': {
'Tier': 'Standard'|'Bulk'|'Expedited'
}
},
RequestPayer='requester'
)
dict
Response Syntax
{
'RequestCharged': 'requester'
}
Response Structure
Sub-resources
Sub-resources are methods that create a new instance of a child resource. This resource's identifiers get passed along to the child. For more information about sub-resources refer to the Resources Introduction Guide.
Creates a ObjectAcl resource.:
object_acl = object_summary.Acl()
Creates a Bucket resource.:
bucket = object_summary.Bucket()
Creates a MultipartUpload resource.:
multipart_upload = object_summary.MultipartUpload('id')
Creates a Object resource.:
object = object_summary.Object()
Creates a ObjectVersion resource.:
object_version = object_summary.Version('id')
Waiters
Waiters provide an interface to wait for a resource to reach a specific state. For more information about waiters refer to the Resources Introduction Guide.
Waits until this ObjectSummary is exists. This method calls S3.Waiter.object_exists.wait() which polls. S3.Client.head_object() every 5 seconds until a successful state is reached. An error is returned after 20 failed checks.
See also: AWS API Documentation
Request Syntax
object_summary.wait_until_exists(
IfMatch='string',
IfModifiedSince=datetime(2015, 1, 1),
IfNoneMatch='string',
IfUnmodifiedSince=datetime(2015, 1, 1),
Range='string',
VersionId='string',
SSECustomerAlgorithm='string',
SSECustomerKey='string',
RequestPayer='requester',
PartNumber=123
)
None
Waits until this ObjectSummary is not exists. This method calls S3.Waiter.object_not_exists.wait() which polls. S3.Client.head_object() every 5 seconds until a successful state is reached. An error is returned after 20 failed checks.
See also: AWS API Documentation
Request Syntax
object_summary.wait_until_not_exists(
IfMatch='string',
IfModifiedSince=datetime(2015, 1, 1),
IfNoneMatch='string',
IfUnmodifiedSince=datetime(2015, 1, 1),
Range='string',
VersionId='string',
SSECustomerAlgorithm='string',
SSECustomerKey='string',
RequestPayer='requester',
PartNumber=123
)
None
A resource representing an Amazon Simple Storage Service (S3) ObjectVersion:
import boto3
s3 = boto3.resource('s3')
object_version = s3.ObjectVersion('bucket_name','object_key','id')
These are the resource's available identifiers:
These are the resource's available attributes:
These are the resource's available actions:
These are the resource's available sub-resources:
Identifiers
Identifiers are properties of a resource that are set upon instantation of the resource. For more information about identifiers refer to the Resources Introduction Guide.
(string) The ObjectVersion's bucket_name identifier. This must be set.
(string) The ObjectVersion's object_key identifier. This must be set.
(string) The ObjectVersion's id identifier. This must be set.
Attributes
Attributes provide access to the properties of a resource. Attributes are lazy-loaded the first time one is accessed via the load() method. For more information about attributes refer to the Resources Introduction Guide.
Actions
Actions call operations on resources. They may automatically handle the passing in of arguments set from identifiers and some attributes. For more information about actions refer to the Resources Introduction Guide.
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.
See also: AWS API Documentation
Request Syntax
response = object_version.delete(
MFA='string',
RequestPayer='requester'
)
dict
Response Syntax
{
'DeleteMarker': True|False,
'VersionId': 'string',
'RequestCharged': 'requester'
}
Response Structure
Retrieves objects from Amazon S3.
See also: AWS API Documentation
Request Syntax
response = object_version.get(
IfMatch='string',
IfModifiedSince=datetime(2015, 1, 1),
IfNoneMatch='string',
IfUnmodifiedSince=datetime(2015, 1, 1),
Range='string',
ResponseCacheControl='string',
ResponseContentDisposition='string',
ResponseContentEncoding='string',
ResponseContentLanguage='string',
ResponseContentType='string',
ResponseExpires=datetime(2015, 1, 1),
SSECustomerAlgorithm='string',
SSECustomerKey='string',
RequestPayer='requester',
PartNumber=123
)
dict
Response Syntax
{
'Body': StreamingBody(),
'DeleteMarker': True|False,
'AcceptRanges': 'string',
'Expiration': 'string',
'Restore': 'string',
'LastModified': datetime(2015, 1, 1),
'ContentLength': 123,
'ETag': 'string',
'MissingMeta': 123,
'VersionId': 'string',
'CacheControl': 'string',
'ContentDisposition': 'string',
'ContentEncoding': 'string',
'ContentLanguage': 'string',
'ContentRange': 'string',
'ContentType': 'string',
'Expires': datetime(2015, 1, 1),
'WebsiteRedirectLocation': 'string',
'ServerSideEncryption': 'AES256'|'aws:kms',
'Metadata': {
'string': 'string'
},
'SSECustomerAlgorithm': 'string',
'SSECustomerKeyMD5': 'string',
'SSEKMSKeyId': 'string',
'StorageClass': 'STANDARD'|'REDUCED_REDUNDANCY'|'STANDARD_IA',
'RequestCharged': 'requester',
'ReplicationStatus': 'COMPLETE'|'PENDING'|'FAILED'|'REPLICA',
'PartsCount': 123,
'TagCount': 123
}
Response Structure
Returns a list of all the available sub-resources for this Resource.
The HEAD operation retrieves metadata from an object without returning the object itself. This operation is useful if you're only interested in an object's metadata. To use HEAD, you must have READ access to the object.
See also: AWS API Documentation
Request Syntax
response = object_version.head(
IfMatch='string',
IfModifiedSince=datetime(2015, 1, 1),
IfNoneMatch='string',
IfUnmodifiedSince=datetime(2015, 1, 1),
Range='string',
SSECustomerAlgorithm='string',
SSECustomerKey='string',
RequestPayer='requester',
PartNumber=123
)
dict
Response Syntax
{
'DeleteMarker': True|False,
'AcceptRanges': 'string',
'Expiration': 'string',
'Restore': 'string',
'LastModified': datetime(2015, 1, 1),
'ContentLength': 123,
'ETag': 'string',
'MissingMeta': 123,
'VersionId': 'string',
'CacheControl': 'string',
'ContentDisposition': 'string',
'ContentEncoding': 'string',
'ContentLanguage': 'string',
'ContentType': 'string',
'Expires': datetime(2015, 1, 1),
'WebsiteRedirectLocation': 'string',
'ServerSideEncryption': 'AES256'|'aws:kms',
'Metadata': {
'string': 'string'
},
'SSECustomerAlgorithm': 'string',
'SSECustomerKeyMD5': 'string',
'SSEKMSKeyId': 'string',
'StorageClass': 'STANDARD'|'REDUCED_REDUNDANCY'|'STANDARD_IA',
'RequestCharged': 'requester',
'ReplicationStatus': 'COMPLETE'|'PENDING'|'FAILED'|'REPLICA',
'PartsCount': 123
}
Response Structure
Sub-resources
Sub-resources are methods that create a new instance of a child resource. This resource's identifiers get passed along to the child. For more information about sub-resources refer to the Resources Introduction Guide.
The following example shows how to use an Amazon S3 bucket resource to list the objects in the bucket.
import boto3
s3 = boto3.resource('s3')
bucket = s3.Bucket('my-bucket')
for obj in bucket.objects.all():
print(obj.key)
This example shows how to list all of the top-level common prefixes in an Amazon S3 bucket:
import boto3
client = boto3.client('s3')
paginator = client.get_paginator('list_objects')
result = paginator.paginate(Bucket='my-bucket', Delimiter='/')
for prefix in result.search('CommonPrefixes'):
print(prefix.get('Prefix'))
The following example shows how to initiate restoration of glacier objects in an Amazon S3 bucket, determine if a restoration is on-going, and determine if a restoration is finished.
import boto3
s3 = boto3.resource('s3')
bucket = s3.Bucket('glacier-bucket')
for obj_sum in bucket.objects.all():
obj = s3.Object(obj_sum.bucket_name, obj_sum.key)
if obj.storage_class == 'GLACIER':
# Try to restore the object if the storage class is glacier and
# the object does not have a completed or ongoing restoration
# request.
if obj.restore is None:
print('Submitting restoration request: %s' % obj.key)
obj.restore_object()
# Print out objects whose restoration is on-going
elif 'ongoing-request="true"' in obj.restore:
print('Restoration in-progress: %s' % obj.key)
# Print out objects whose restoration is complete
elif 'ongoing-request="false"' in obj.restore:
print('Restoration complete: %s' % obj.key)
This example shows how to use SSE-C to upload objects using server side encryption with a customer provided key.
First, we'll need a 32 byte key. For this example, we'll randomly generate a key but you can use any 32 byte key you want. Remember, you must the same key to download the object. If you lose the encryption key, you lose the object.
Also note how we don't have to provide the SSECustomerKeyMD5. Boto3 will automatically compute this value for us.
import boto3
import os
BUCKET = 'your-bucket-name'
KEY = os.urandom(32)
s3 = boto3.client('s3')
print("Uploading S3 object with SSE-C")
s3.put_object(Bucket=BUCKET,
Key='encrypt-key',
Body=b'foobar',
SSECustomerKey=KEY,
SSECustomerAlgorithm='AES256')
print("Done")
# Getting the object:
print("Getting S3 object...")
# Note how we're using the same ``KEY`` we
# created earlier.
response = s3.get_object(Bucket=BUCKET,
Key='encrypt-key',
SSECustomerKey=KEY,
SSECustomerAlgorithm='AES256')
print("Done, response body:")
print(response['Body'].read())