The parameters to request an abort of 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.
Inheritance: Amazon.Runtime.AmazonWebServiceRequest
示例#1
0
        private void AbortMultipartUpload(MultipartUpload u, AmazonS3Client client)
        {
            var request = new AbortMultipartUploadRequest
            {
                BucketName = _bucket,
                Key = u.Key,
                UploadId = u.UploadId,
            };

            client.AbortMultipartUpload(request);
        }
 private AbortMultipartUploadRequest ConstructAbortMultipartUploadRequest(MultipartUpload upload)
             {
                 var abortRequest = new AbortMultipartUploadRequest()
                 {
                     BucketName = this._bucketName,
                     Key = upload.Key,
                     UploadId = upload.UploadId,
                 };
                 ((Amazon.Runtime.Internal.IAmazonWebServiceRequest)abortRequest).AddBeforeRequestHandler(this.RequestEventHandler);
     return abortRequest;
 }
 private AbortMultipartUploadRequest ConstructAbortMultipartUploadRequest(MultipartUpload upload)
             {
                 var abortRequest = new AbortMultipartUploadRequest()
                 {
                     BucketName = this._bucketName,
                     Key = upload.Key,
                     UploadId = upload.UploadId,
                 };
                 abortRequest.BeforeRequestEvent += this.RequestEventHandler;
     return abortRequest;
 }
        public void Abort()
        {
            // No need to cancel if the uploadid call is the thing that failed
            if (_uploadId.IsFaulted || !_uploadId.IsCompleted) { return; }

            var abortMPURequest = new AbortMultipartUploadRequest
            {
                BucketName = _bucket,
                Key = _key,
                UploadId = _uploadId.Result
            };

            _client.AbortMultipartUpload(abortMPURequest);
        }
        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);
        }
示例#6
0
 /// <summary>
 /// Aborts a multipart upload.
 /// 
 /// 
 /// <para>
 /// 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.
 /// </para>
 /// </summary>
 /// <param name="bucketName">A property of AbortMultipartUploadRequest used to execute the AbortMultipartUpload service method.</param>
 /// <param name="key">A property of AbortMultipartUploadRequest used to execute the AbortMultipartUpload service method.</param>
 /// <param name="uploadId">A property of AbortMultipartUploadRequest used to execute the AbortMultipartUpload service method.</param>
 /// <param name="cancellationToken">
 ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
 /// </param>
 /// 
 /// <returns>The response from the AbortMultipartUpload service method, as returned by S3.</returns>
 public Task<AbortMultipartUploadResponse> AbortMultipartUploadAsync(string bucketName, string key, string uploadId, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
 {
     var request = new AbortMultipartUploadRequest();
     request.BucketName = bucketName;
     request.Key = key;
     request.UploadId = uploadId;
     return AbortMultipartUploadAsync(request, cancellationToken);
 }
示例#7
0
 /// <summary>
 /// Aborts a multipart upload.
 /// 
 /// 
 /// <para>
 /// 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.
 /// </para>
 /// </summary>
 /// <param name="bucketName">A property of AbortMultipartUploadRequest used to execute the AbortMultipartUpload service method.</param>
 /// <param name="key">A property of AbortMultipartUploadRequest used to execute the AbortMultipartUpload service method.</param>
 /// <param name="uploadId">A property of AbortMultipartUploadRequest used to execute the AbortMultipartUpload service method.</param>
 /// 
 /// <returns>The response from the AbortMultipartUpload service method, as returned by S3.</returns>
 public AbortMultipartUploadResponse AbortMultipartUpload(string bucketName, string key, string uploadId)
 {
     var request = new AbortMultipartUploadRequest();
     request.BucketName = bucketName;
     request.Key = key;
     request.UploadId = uploadId;
     return AbortMultipartUpload(request);
 }
        /// <summary>
        /// Initiates the asynchronous execution of the AbortMultipartUpload operation.
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the AbortMultipartUpload operation on AmazonS3Client.</param>
        /// <param name="callback">An AsyncCallback delegate that is invoked when the operation completes.</param>
        /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
        ///          procedure using the AsyncState property.</param>
        /// 
        /// <returns>An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking EndAbortMultipartUpload
        ///         operation.</returns>
        public IAsyncResult BeginAbortMultipartUpload(AbortMultipartUploadRequest request, AsyncCallback callback, object state)
        {
            var marshaller = new AbortMultipartUploadRequestMarshaller();
            var unmarshaller = AbortMultipartUploadResponseUnmarshaller.Instance;

            return BeginInvoke<AbortMultipartUploadRequest>(request, marshaller, unmarshaller,
                callback, state);
        }
示例#9
0
        internal AbortMultipartUploadResponse AbortMultipartUpload(AbortMultipartUploadRequest request)
        {
            var marshaller = new AbortMultipartUploadRequestMarshaller();
            var unmarshaller = AbortMultipartUploadResponseUnmarshaller.Instance;

            return Invoke<AbortMultipartUploadRequest,AbortMultipartUploadResponse>(request, marshaller, unmarshaller);
        }
 IAsyncResult invokeAbortMultipartUpload(AbortMultipartUploadRequest abortMultipartUploadRequest, AsyncCallback callback, object state, bool synchronized)
 {
     IRequest irequest = new AbortMultipartUploadRequestMarshaller().Marshall(abortMultipartUploadRequest);
     var unmarshaller = AbortMultipartUploadResponseUnmarshaller.GetInstance();
     AsyncResult result = new AsyncResult(irequest, callback, state, synchronized, signer, unmarshaller);
     Invoke(result);
     return result;
 }
 /// <summary>
 /// <para>Aborts a multipart upload.</para>
 /// </summary>
 /// 
 /// <param name="abortMultipartUploadRequest">Container for the necessary parameters to execute the AbortMultipartUpload service method on
 ///          AmazonS3.</param>
 /// 
 public AbortMultipartUploadResponse AbortMultipartUpload(AbortMultipartUploadRequest abortMultipartUploadRequest)
 {
     IAsyncResult asyncResult = invokeAbortMultipartUpload(abortMultipartUploadRequest, null, null, true);
     return EndAbortMultipartUpload(asyncResult);
 }
示例#12
0
        /// <summary>
        /// <para>Aborts a multipart upload.</para>
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the AbortMultipartUpload service method on
        /// AmazonS3.</param>
		public AbortMultipartUploadResponse AbortMultipartUpload(AbortMultipartUploadRequest request)
        {
            var task = AbortMultipartUploadAsync(request);
            try
            {
                return task.Result;
            }
            catch(AggregateException e)
            {
                ExceptionDispatchInfo.Capture(e.InnerException).Throw();
                return null;
            }
        }
示例#13
0
		private void Init()
		{
			var initiateRequest = new InitiateMultipartUploadRequest
			{
				BucketName = this.bucketName,
				Key = this.fileName
			};

			this.initResponse = client.InitiateMultipartUpload(initiateRequest);

			this.abortMPURequest = new AbortMultipartUploadRequest
			{
				BucketName = this.bucketName,
				Key = this.fileName,
				UploadId = this.initResponse.UploadId
			};

			this.uploadResponses = new List<UploadPartResponse>();
		}
示例#14
0
        public override void AbortChunkedUpload(string domain, string path, string uploadId)
        {
            var key = MakePath(domain, path);

            var request = new AbortMultipartUploadRequest
                {
                    BucketName = _bucket,
                    Key = key,
                    UploadId = uploadId
                };

            using (var s3 = GetClient())
            {
                s3.AbortMultipartUpload(request);
            }
        }
示例#15
0
 /// <summary>
 /// Aborts a multipart upload.
 /// 
 /// 
 /// <para>
 /// 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.
 /// </para>
 /// This API is supported only when AWSConfigs.HttpClient is set to AWSConfigs.HttpClientOption.UnityWebRequest, the default value of this configuration option is AWSConfigs.HttpClientOption.UnityWWW
 /// </summary>
 /// <param name="bucketName">A property of AbortMultipartUploadRequest used to execute the AbortMultipartUpload service method.</param>
 /// <param name="key">A property of AbortMultipartUploadRequest used to execute the AbortMultipartUpload service method.</param>
 /// <param name="uploadId">A property of AbortMultipartUploadRequest used to execute the AbortMultipartUpload service method.</param>
 /// <param name="callback">An Action delegate that is invoked when the operation completes.</param>
 /// <param name="options">
 ///     A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
 ///     procedure using the AsyncState property.
 /// </param>
 /// 
 /// <returns>The response from the AbortMultipartUpload service method, as returned by S3.</returns>
 public void AbortMultipartUploadAsync(string bucketName, string key, string uploadId,  AmazonServiceCallback<AbortMultipartUploadRequest, AbortMultipartUploadResponse> callback, AsyncOptions options = null)
 {
     var request = new AbortMultipartUploadRequest();
     request.BucketName = bucketName;
     request.Key = key;
     request.UploadId = uploadId;
     AbortMultipartUploadAsync(request, callback, options);
 }
示例#16
0
 /// <summary>
 /// Initiates the asynchronous execution of the AbortMultipartUpload operation.
 /// This API is supported only when AWSConfigs.HttpClient is set to AWSConfigs.HttpClientOption.UnityWebRequest, the default value for this configuration option is AWSConfigs.HttpClientOption.UnityWWW
 /// </summary>
 /// 
 /// <param name="request">Container for the necessary parameters to execute the AbortMultipartUpload operation on AmazonS3Client.</param>
 /// <param name="callback">An Action delegate that is invoked when the operation completes.</param>
 /// <param name="options">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
 ///          procedure using the AsyncState property.</param>
 public void AbortMultipartUploadAsync(AbortMultipartUploadRequest request, AmazonServiceCallback<AbortMultipartUploadRequest, AbortMultipartUploadResponse> callback, AsyncOptions options = null)
 {
     if (AWSConfigs.HttpClient == AWSConfigs.HttpClientOption.UnityWWW)
     {
         throw new InvalidOperationException("AbortMultipartUpload is only allowed with AWSConfigs.HttpClientOption.UnityWebRequest API option");
     }
     options = options == null?new AsyncOptions():options;
     var marshaller = new AbortMultipartUploadRequestMarshaller();
     var unmarshaller = AbortMultipartUploadResponseUnmarshaller.Instance;
     Action<AmazonWebServiceRequest, AmazonWebServiceResponse, Exception, AsyncOptions> callbackHelper = null;
     if(callback !=null )
         callbackHelper = (AmazonWebServiceRequest req, AmazonWebServiceResponse res, Exception ex, AsyncOptions ao) => { 
             AmazonServiceResult<AbortMultipartUploadRequest,AbortMultipartUploadResponse> responseObject 
                     = new AmazonServiceResult<AbortMultipartUploadRequest,AbortMultipartUploadResponse>((AbortMultipartUploadRequest)req, (AbortMultipartUploadResponse)res, ex , ao.State);    
                 callback(responseObject); 
         };
     BeginInvoke<AbortMultipartUploadRequest>(request, marshaller, unmarshaller, options, callbackHelper);
 }
示例#17
0
        /// <summary>
        /// <para>Aborts a multipart upload.</para>
        /// </summary>
        /// 
        /// <param name="abortMultipartUploadRequest">Container for the necessary parameters to execute the AbortMultipartUpload service method on
        /// AmazonS3.</param>
        /// <param name="cancellationToken">
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// </param>
		public async Task<AbortMultipartUploadResponse> AbortMultipartUploadAsync(AbortMultipartUploadRequest abortMultipartUploadRequest, CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new AbortMultipartUploadRequestMarshaller();
            var unmarshaller = AbortMultipartUploadResponseUnmarshaller.GetInstance();
            var response = await Invoke<IRequest, AbortMultipartUploadRequest, AbortMultipartUploadResponse>(abortMultipartUploadRequest, marshaller, unmarshaller, signer, cancellationToken)
                .ConfigureAwait(continueOnCapturedContext: false);
            return response;
        }
 /// <summary>
 /// Initiates the asynchronous execution of the AbortMultipartUpload operation.
 /// <seealso cref="Amazon.S3.IAmazonS3.AbortMultipartUpload"/>
 /// </summary>
 /// 
 /// <param name="abortMultipartUploadRequest">Container for the necessary parameters to execute the AbortMultipartUpload operation on
 ///          AmazonS3.</param>
 /// <param name="callback">An AsyncCallback delegate that is invoked when the operation completes.</param>
 /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
 ///          procedure using the AsyncState property.</param>
 public IAsyncResult BeginAbortMultipartUpload(AbortMultipartUploadRequest abortMultipartUploadRequest, AsyncCallback callback, object state)
 {
     return invokeAbortMultipartUpload(abortMultipartUploadRequest, callback, state, false);
 }
示例#19
0
        /// <summary>
        /// <para>Aborts a multipart upload.</para>
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the AbortMultipartUpload service method on
        /// AmazonS3.</param>
		public AbortMultipartUploadResponse AbortMultipartUpload(AbortMultipartUploadRequest request)
        {
            var task = AbortMultipartUploadAsync(request);
            try
            {
                return task.Result;
            }
            catch(AggregateException e)
            {
                throw e.InnerException;
            }
        }
        /// <summary>
        /// Asynchronously abort a multipart Upload operation.
        /// </summary>
        /// <param name="existingBucketName"></param>
        /// <param name="keyName"></param>
        /// <param name="uploadID"></param>
        /// <param name="token"></param>
        /// <returns></returns>
        public async Task AbortMultiPartUploadAsync(string existingBucketName, string keyName, string uploadId, CancellationToken token)
        {
            token.ThrowIfCancellationRequested();

            _log.Debug("Called AbortMultiPartUploadAsync with parameters keyName = \"" + keyName +
                "\", UploadId = \"" + uploadId + "\".");

            AbortMultipartUploadRequest request = new AbortMultipartUploadRequest()
            {
                BucketName = existingBucketName,
                Key = keyName,
                UploadId = uploadId
            };

            try
            {
                await s3Client.AbortMultipartUploadAsync(request, token).ConfigureAwait(false);
            }
            catch(Exception e)
            {
                if (!(e is TaskCanceledException || e is OperationCanceledException))
                {
                    string messagePart = " with parameters keyName = \"" + keyName +
                        "\", UploadId = \"" + uploadId + "\"";

                    this.LogAmazonException(messagePart, e);
                }

                throw;
            }
        }
示例#21
0
        /// <summary>
        /// Initiates the asynchronous execution of the AbortMultipartUpload operation.
        /// <seealso cref="Amazon.S3.IAmazonS3.AbortMultipartUpload"/>
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the AbortMultipartUpload operation.</param>
        /// <param name="cancellationToken">
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// </param>
        /// <returns>The task object representing the asynchronous operation.</returns>
		public Task<AbortMultipartUploadResponse> AbortMultipartUploadAsync(AbortMultipartUploadRequest request, CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new AbortMultipartUploadRequestMarshaller();
            var unmarshaller = AbortMultipartUploadResponseUnmarshaller.GetInstance();
            return Invoke<IRequest, AbortMultipartUploadRequest, AbortMultipartUploadResponse>(request, marshaller, unmarshaller, signer, cancellationToken);
        }
示例#22
0
        /// <summary>
        /// Initiates the asynchronous execution of the AbortMultipartUpload operation.
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the AbortMultipartUpload operation.</param>
        /// <param name="cancellationToken">
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// </param>
        /// <returns>The task object representing the asynchronous operation.</returns>
        public Task<AbortMultipartUploadResponse> AbortMultipartUploadAsync(AbortMultipartUploadRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new AbortMultipartUploadRequestMarshaller();
            var unmarshaller = AbortMultipartUploadResponseUnmarshaller.Instance;

            return InvokeAsync<AbortMultipartUploadRequest,AbortMultipartUploadResponse>(request, marshaller, 
                unmarshaller, cancellationToken);
        }
 private async Task<AbortMultipartUploadResponse> AbortAsync(AbortMultipartUploadRequest abortRequest, CancellationTokenSource internalCts,
     CancellationToken cancellationToken, SemaphoreSlim asyncThrottler)
 {
     try
     {
         return await this._s3Client.AbortMultipartUploadAsync(abortRequest, cancellationToken)
             .ConfigureAwait(continueOnCapturedContext: false);
     }
     catch (Exception exception)
     {
         if (!(exception is OperationCanceledException))
         {
             // Cancel scheduling any more tasks.
             internalCts.Cancel();
         }
         throw;
     }
     finally
     {
         asyncThrottler.Release();
     }
 }