abortMultipartUpload method

Future<AbortMultipartUploadOutput> abortMultipartUpload({
  1. required String bucket,
  2. required String key,
  3. required String uploadId,
  4. String? expectedBucketOwner,
  5. RequestPayer? requestPayer,
})

This operation aborts a multipart upload. After a multipart upload is aborted, no additional parts can be uploaded using that upload ID. The storage consumed by any previously uploaded parts will be freed. However, if any part uploads are currently in progress, those part uploads might or might not succeed. As a result, it might be necessary to abort a given multipart upload multiple times in order to completely free all storage consumed by all parts.

To verify that all parts have been removed, so you don't get charged for the part storage, you should call the ListParts operation and ensure that the parts list is empty.

For information about permissions required to use the multipart upload API, see Multipart Upload API and Permissions.

The following operations are related to AbortMultipartUpload:

May throw NoSuchUpload.

Parameter bucket : The bucket name to which the upload was taking place.

When using this API with an access point, you must direct requests to the access point hostname. The access point hostname takes the form AccessPointName-AccountId.s3-accesspoint.Region.amazonaws.com. When using this operation with an access point through the AWS 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 Simple Storage Service Developer Guide.

When using this API with Amazon S3 on Outposts, you must direct requests to the S3 on Outposts hostname. The S3 on Outposts hostname takes the form AccessPointName-AccountId.outpostID.s3-outposts.Region.amazonaws.com. When using this operation using S3 on Outposts through the AWS SDKs, you provide the Outposts bucket ARN in place of the bucket name. For more information about S3 on Outposts ARNs, see Using S3 on Outposts in the Amazon Simple Storage Service Developer Guide.

Parameter key : Key of the object for which the multipart upload was initiated.

Parameter uploadId : Upload ID that identifies the multipart upload.

Parameter expectedBucketOwner : The account id of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP 403 (Access Denied) error.

Implementation

Future<AbortMultipartUploadOutput> abortMultipartUpload({
  required String bucket,
  required String key,
  required String uploadId,
  String? expectedBucketOwner,
  RequestPayer? requestPayer,
}) async {
  ArgumentError.checkNotNull(bucket, 'bucket');
  ArgumentError.checkNotNull(key, 'key');
  _s.validateStringLength(
    'key',
    key,
    1,
    1152921504606846976,
    isRequired: true,
  );
  ArgumentError.checkNotNull(uploadId, 'uploadId');
  final headers = <String, String>{
    if (expectedBucketOwner != null)
      'x-amz-expected-bucket-owner': expectedBucketOwner.toString(),
    if (requestPayer != null) 'x-amz-request-payer': requestPayer.toValue(),
  };
  final $query = <String, List<String>>{
    'uploadId': [uploadId],
  };
  final $result = await _protocol.sendRaw(
    method: 'DELETE',
    requestUri:
        '/${Uri.encodeComponent(bucket)}/${key.split('/').map(Uri.encodeComponent).join('/')}',
    queryParams: $query,
    headers: headers,
    exceptionFnMap: _exceptionFns,
  );
  final $elem = await _s.xmlFromResponse($result);
  return AbortMultipartUploadOutput(
    requestCharged: _s
        .extractHeaderStringValue($result.headers, 'x-amz-request-charged')
        ?.toRequestCharged(),
  );
}