Amazon.S3.Transfer.Internal.AbortMultipartUploadsCommand.Execute C# (CSharp) Method

Execute() public method

public Execute ( ) : void
return void
        public override void Execute()
        {
            if (string.IsNullOrEmpty(this._bucketName))
            {
                throw new InvalidOperationException("The bucketName Specified is null or empty!");
            }

            ListMultipartUploadsResponse listResponse = new ListMultipartUploadsResponse();
            do
            {
                ListMultipartUploadsRequest listRequest = new ListMultipartUploadsRequest()
                {
                    BucketName = this._bucketName,
                    KeyMarker = listResponse.KeyMarker,
                    UploadIdMarker = listResponse.NextUploadIdMarker,
                };
                listRequest.BeforeRequestEvent += this.RequestEventHandler;

                listResponse = this._s3Client.ListMultipartUploads(listRequest);
                foreach (MultipartUpload upload in listResponse.MultipartUploads)
                {
                    if (upload.Initiated < this._initiatedDate)
                    {
                        var abortRequest = new AbortMultipartUploadRequest()
                        {
                            BucketName = this._bucketName,
                            Key = upload.Key,
                            UploadId = upload.UploadId,
                        };
                        abortRequest.BeforeRequestEvent += this.RequestEventHandler;

                        this._s3Client.AbortMultipartUpload(abortRequest);
                    }
                }
            }
            while (listResponse.IsTruncated);
        }
    }

Usage Example

コード例 #1
0
 /// <summary>
 /// 	Aborts the multipart uploads that were initiated before the specified date.
 /// </summary>
 /// <param name="bucketName">
 /// 	The name of the bucket containing multipart uploads.
 /// </param>
 /// <param name="initiatedDate">
 /// 	The date before which the multipart uploads were initiated.
 /// </param>
 public void AbortMultipartUploads(string bucketName, DateTime initiatedDate)
 {
     BaseCommand command = new AbortMultipartUploadsCommand(this._s3Client, bucketName, initiatedDate);
     command.Execute();
 }
AbortMultipartUploadsCommand