listParts method
Lists the parts that have been uploaded for a specific multipart upload.
To use this operation, you must provide the upload ID in the
request. You obtain this uploadID by sending the initiate multipart upload
request through CreateMultipartUpload.
The ListParts request returns a maximum of 1,000 uploaded
parts. The limit of 1,000 parts is also the default value. You can
restrict the number of parts in a response by specifying the
max-parts request parameter. If your multipart upload
consists of more than 1,000 parts, the response returns an
IsTruncated field with the value of true, and a
NextPartNumberMarker element. To list remaining uploaded
parts, in subsequent ListParts requests, include the
part-number-marker query string parameter and set its value
to the NextPartNumberMarker field value from the previous
response.
For more information on multipart uploads, see Uploading Objects Using Multipart Upload in the Amazon S3 User Guide.
- Permissions
-
-
General purpose bucket permissions - For information about
permissions required to use the multipart upload API, see Multipart
Upload and Permissions in the Amazon S3 User Guide.
If the upload was created using server-side encryption with Key Management Service (KMS) keys (SSE-KMS) or dual-layer server-side encryption with Amazon Web Services KMS keys (DSSE-KMS), you must have permission to the
kms:Decryptaction for theListPartsrequest to succeed. -
Directory bucket permissions - To grant access to this API
operation on a directory bucket, we recommend that you use the
CreateSessionAPI operation for session-based authorization. Specifically, you grant thes3express:CreateSessionpermission to the directory bucket in a bucket policy or an IAM identity-based policy. Then, you make theCreateSessionAPI call on the bucket to obtain a session token. With the session token in your request header, you can make API requests to this operation. After the session token expires, you make anotherCreateSessionAPI call to generate a new session token for use. Amazon Web Services CLI or SDKs create session and refresh the session token automatically to avoid service interruptions when a session expires. For more information about authorization, seeCreateSession.
-
General purpose bucket permissions - For information about
permissions required to use the multipart upload API, see Multipart
Upload and Permissions in the Amazon S3 User Guide.
- HTTP Host header syntax
-
Directory buckets - The HTTP Host header syntax is
Bucket-name.s3express-zone-id.region-code.amazonaws.com.
ListParts:
- CreateMultipartUpload
- UploadPart
- CompleteMultipartUpload
- AbortMultipartUpload
- GetObjectAttributes
- ListMultipartUploads
Parameter bucket :
The name of the bucket to which the parts are being uploaded.
Directory buckets - When you use this operation with a directory
bucket, you must use virtual-hosted-style requests in the format
Bucket-name.s3express-zone-id.region-code.amazonaws.com.
Path-style requests are not supported. Directory bucket names must be
unique in the chosen Zone (Availability Zone or Local Zone). Bucket names
must follow the format
bucket-base-name--zone-id--x-s3 (for example,
amzn-s3-demo-bucket--usw2-az1--x-s3). For information
about bucket naming restrictions, see Directory
bucket naming rules in the Amazon S3 User Guide.
Access points - When you use this action with an access point for
general purpose buckets, you must provide the alias of the access point in
place of the bucket name or specify the access point ARN. When you use
this action with an access point for directory buckets, you must provide
the access point name in place of the bucket name. When using the access
point ARN, you must direct requests to the access point hostname. The
access point hostname takes the form
AccessPointName-AccountId.s3-accesspoint.Region.amazonaws.com.
When using this action with an access point through the Amazon Web
Services SDKs, you provide the access point ARN in place of the bucket
name. For more information about access point ARNs, see Using
access points in the Amazon S3 User Guide.
S3 on Outposts - When you use this action with S3 on Outposts, you
must direct requests to the S3 on Outposts hostname. The S3 on Outposts
hostname takes the form
AccessPointName-AccountId.outpostID.s3-outposts.Region.amazonaws.com.
When you use this action with S3 on Outposts, the destination bucket must
be the Outposts access point ARN or the access point alias. For more
information about S3 on Outposts, see What
is S3 on Outposts? in the Amazon S3 User Guide.
Parameter key :
Object key for which the multipart upload was initiated.
Parameter uploadId :
Upload ID identifying the multipart upload whose parts are being listed.
Parameter expectedBucketOwner :
The account ID of the expected bucket owner. If the account ID that you
provide does not match the actual owner of the bucket, the request fails
with the HTTP status code 403 Forbidden (access denied).
Parameter maxParts :
Sets the maximum number of parts to return.
Parameter partNumberMarker :
Specifies the part after which listing should begin. Only parts with
higher part numbers will be listed.
Parameter sSECustomerAlgorithm :
The server-side encryption (SSE) algorithm used to encrypt the object.
This parameter is needed only when the object was created using a checksum
algorithm. For more information, see Protecting
data using SSE-C keys in the Amazon S3 User Guide.
Parameter sSECustomerKey :
The server-side encryption (SSE) customer managed key. This parameter is
needed only when the object was created using a checksum algorithm. For
more information, see Protecting
data using SSE-C keys in the Amazon S3 User Guide.
Parameter sSECustomerKeyMD5 :
The MD5 server-side encryption (SSE) customer managed key. This parameter
is needed only when the object was created using a checksum algorithm. For
more information, see Protecting
data using SSE-C keys in the Amazon S3 User Guide.
Implementation
Future<ListPartsOutput> listParts({
required String bucket,
required String key,
required String uploadId,
String? expectedBucketOwner,
int? maxParts,
String? partNumberMarker,
RequestPayer? requestPayer,
String? sSECustomerAlgorithm,
String? sSECustomerKey,
String? sSECustomerKeyMD5,
}) async {
final headers = <String, String>{
if (expectedBucketOwner != null)
'x-amz-expected-bucket-owner': expectedBucketOwner.toString(),
if (requestPayer != null) 'x-amz-request-payer': requestPayer.value,
if (sSECustomerAlgorithm != null)
'x-amz-server-side-encryption-customer-algorithm':
sSECustomerAlgorithm.toString(),
if (sSECustomerKey != null)
'x-amz-server-side-encryption-customer-key': sSECustomerKey.toString(),
if (sSECustomerKeyMD5 != null)
'x-amz-server-side-encryption-customer-key-MD5':
sSECustomerKeyMD5.toString(),
};
final $query = <String, List<String>>{
'uploadId': [uploadId],
if (maxParts != null) 'max-parts': [maxParts.toString()],
if (partNumberMarker != null) 'part-number-marker': [partNumberMarker],
};
final $result = await _protocol.sendRaw(
method: 'GET',
requestUri:
'/${Uri.encodeComponent(bucket)}/${key.split('/').map(Uri.encodeComponent).join('/')}?x-id=ListParts',
queryParams: $query,
headers: headers,
exceptionFnMap: _exceptionFns,
);
final $elem = await _s.xmlFromResponse($result);
return ListPartsOutput(
bucket: _s.extractXmlStringValue($elem, 'Bucket'),
checksumAlgorithm: _s
.extractXmlStringValue($elem, 'ChecksumAlgorithm')
?.let(ChecksumAlgorithm.fromString),
checksumType: _s
.extractXmlStringValue($elem, 'ChecksumType')
?.let(ChecksumType.fromString),
initiator: _s.extractXmlChild($elem, 'Initiator')?.let(Initiator.fromXml),
isTruncated: _s.extractXmlBoolValue($elem, 'IsTruncated'),
key: _s.extractXmlStringValue($elem, 'Key'),
maxParts: _s.extractXmlIntValue($elem, 'MaxParts'),
nextPartNumberMarker:
_s.extractXmlStringValue($elem, 'NextPartNumberMarker'),
owner: _s.extractXmlChild($elem, 'Owner')?.let(Owner.fromXml),
partNumberMarker: _s.extractXmlStringValue($elem, 'PartNumberMarker'),
parts: $elem.findElements('Part').map(Part.fromXml).toList(),
storageClass: _s
.extractXmlStringValue($elem, 'StorageClass')
?.let(StorageClass.fromString),
uploadId: _s.extractXmlStringValue($elem, 'UploadId'),
abortDate:
_s.extractHeaderDateTimeValue($result.headers, 'x-amz-abort-date'),
abortRuleId:
_s.extractHeaderStringValue($result.headers, 'x-amz-abort-rule-id'),
requestCharged: _s
.extractHeaderStringValue($result.headers, 'x-amz-request-charged')
?.let(RequestCharged.fromString),
);
}