response = client.list_objects(
Bucket='string',
Delimiter='string',
EncodingType='url',
Marker='string',
MaxKeys=123,
Prefix='string',
RequestPayer='requester',
ExpectedBucketOwner='string'
)
{
'IsTruncated': True|False,
'Marker': 'string',
'NextMarker': 'string',
'Contents': [
{
'Key': 'string',
'LastModified': datetime(2015, 1, 1),
'ETag': 'string',
'Size': 123,
'StorageClass': 'STANDARD'|'REDUCED_REDUNDANCY'|'GLACIER'|'STANDARD_IA'|'ONEZONE_IA'|'INTELLIGENT_TIERING'|'DEEP_ARCHIVE'|'OUTPOSTS',
'Owner': {
'DisplayName': 'string',
'ID': 'string'
}
},
],
'Name': 'string',
'Prefix': 'string',
'Delimiter': 'string',
'MaxKeys': 123,
'CommonPrefixes': [
{
'Prefix': 'string'
},
],
'EncodingType': 'url'
}
(dict) –
IsTruncated (boolean) --一个标志,指示 Amazon S3 是否返回了满足搜索条件的所有结果;
Marker (string) --指示存储桶列表中的何处开始。如果标记与请求一起发送,则标记包含在响应中;
NextMarker (string) --当响应被截断时(响应中的 IsTruncated 元素值为 true),您可以使用该字段中的键名作为后续请求中的标记,以获取下一组对象。Amazon S3 按字母顺序列出对象 注意:仅当您指定了分隔符请求参数时,才会返回此元素。如果响应中没有包含NextMarker并且被截断了,可以使用响应中最后一个Key的值作为后续请求中的标记,获取下一组对象键;
Contents (list) --返回的每个对象的元数据.
(dict) --对象由数据及其描述性元数据组成;
Key (string) --您分配给对象的名称。您使用对象键来检索对象;
LastModified (datetime) --对象的创建日期;
ETag (string) --实体标签是对象的散列。ETag 仅反映对象内容的更改,而不反映其元数据。ETag 可能是也可能不是对象数据的 MD5 摘要。它是否取决于对象是如何创建的以及它是如何加密的,如下所述:
Size (integer) --对象的大小(以字节为单位)
StorageClass (string) --用于存储对象的存储类
Owner (dict) --用于存储对象的存储类
DisplayName (string) --对象的所有者
response = client.list_objects_v2 (
Bucket = 'string' ,
Delimiter = 'string' ,
EncodingType = 'url' ,
MaxKeys = 123 ,
Prefix = 'string' ,
ContinuationToken = 'string' ,
FetchOwner = True | False ,
StartAfter = 'string' ,
RequestPayer = 'requester' ,
ExpectedBucketOwner = 'string'
)
{
'IsTruncated': True|False,
'Contents': [
{
'Key': 'string',
'LastModified': datetime(2015, 1, 1),
'ETag': 'string',
'Size': 123,
'StorageClass': 'STANDARD'|'REDUCED_REDUNDANCY'|'GLACIER'|'STANDARD_IA'|'ONEZONE_IA'|'INTELLIGENT_TIERING'|'DEEP_ARCHIVE'|'OUTPOSTS',
'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'
}
定义:删除对象的空版本(如果有)并插入删除标记,它成为对象的最新版本。如果没有空版本,Amazon S3 不会删除任何对象,但仍会响应命令成功。要删除特定版本,您必须是存储桶所有者并且必须使用版本 ID 子资源。使用此子资源会永久删除版本。如果删除的对象是删除标记,Amazon S3会将响应标头x-amz-delete-marker 设置为 true。如果要删除的对象位于存储桶版本控制配置启用 MFA 删除的存储桶中,则必须在 DELETE versionId请求中包含x-amz-mfa请求标头。包含x-amz-mfa 的请求必须使用 HTTPS。
请求语法:
response = client.delete_object(
Bucket='string',
Key='string',
MFA='string',
VersionId='string',
RequestPayer='requester',
BypassGovernanceRetention=True|False,
ExpectedBucketOwner='string'
)
{
'DeleteMarker': True|False,
'VersionId': 'string',
'RequestCharged': 'requester'
}
response = client.delete_object(
Bucket='examplebucket',
Key='objectkey.jpg',
)
print(response)
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,
ExpectedBucketOwner='string'
)
{
'DeleteMarker': True|False,
'AcceptRanges': 'string',
'Expiration': 'string',
'Restore': 'string',
'ArchiveStatus': 'ARCHIVE_ACCESS'|'DEEP_ARCHIVE_ACCESS',
'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',
'BucketKeyEnabled': True|False,
'StorageClass': 'STANDARD'|'REDUCED_REDUNDANCY'|'STANDARD_IA'|'ONEZONE_IA'|'INTELLIGENT_TIERING'|'GLACIER'|'DEEP_ARCHIVE'|'OUTPOSTS',
'RequestCharged': 'requester',
'ReplicationStatus': 'COMPLETE'|'PENDING'|'FAILED'|'REPLICA',
'PartsCount': 123,
'ObjectLockMode': 'GOVERNANCE'|'COMPLIANCE',
'ObjectLockRetainUntilDate': datetime(2015, 1, 1),
'ObjectLockLegalHoldStatus': 'ON'|'OFF'
}
response = client.head_object(
Bucket='examplebucket',
Key='HappyFace.jpg',
)
print(response)
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'|'ONEZONE_IA'|'INTELLIGENT_TIERING'|'GLACIER'|'DEEP_ARCHIVE'|'OUTPOSTS',
WebsiteRedirectLocation='string',
SSECustomerAlgorithm='string',
SSECustomerKey='string',
SSEKMSKeyId='string',
SSEKMSEncryptionContext='string',
BucketKeyEnabled=True|False,
RequestPayer='requester',
Tagging='string',
ObjectLockMode='GOVERNANCE'|'COMPLIANCE',
ObjectLockRetainUntilDate=datetime(2015, 1, 1),
ObjectLockLegalHoldStatus='ON'|'OFF',
ExpectedBucketOwner='string'
)
{
'Expiration': 'string',
'ETag': 'string',
'ServerSideEncryption': 'AES256'|'aws:kms',
'VersionId': 'string',
'SSECustomerAlgorithm': 'string',
'SSECustomerKeyMD5': 'string',
'SSEKMSKeyId': 'string',
'SSEKMSEncryptionContext': 'string',
'BucketKeyEnabled': True|False,
'RequestCharged': 'requester'
}
response = client.put_object(
Body='filetoupload',
Bucket='examplebucket',
Key='objectkey',
)
print(response)
输出:
{
'ETag': '"6805f2cfc46c0f04559748bb039d69ae"',
'VersionId': 'Bvq0EDKxOcXLJXNo_Lkz37eM3R4pfzyQ',
'ResponseMetadata': {
'...': '...',
},
}