Container for the parameters to the CompleteMultipartUpload operation. You call this operation to inform Amazon Glacier that all the archive parts have been uploaded and that Amazon Glacier can now assemble the archive from the uploaded parts. After assembling and saving the archive to the vault, Amazon Glacier returns the URI path of the newly created archive resource. Using the URI path, you can then access the archive. After you upload an archive, you should save the archive ID returned to retrieve the archive at a later point. You can also get the vault inventory to obtain a list of archive IDs in a vault. For more information, see InitiateJob.

In the request, you must include the computed SHA256 tree hash of the entire archive you have uploaded. For information about computing a SHA256 tree hash, see Computing Checksums. On the server side, Amazon Glacier also constructs the SHA256 tree hash of the assembled archive. If the values match, Amazon Glacier saves the archive to the vault; otherwise, it returns an error, and the operation fails. The ListParts operation returns a list of parts uploaded for a specific multipart upload. It includes checksum information for each uploaded part that can be used to debug a bad checksum issue.

Additionally, Amazon Glacier also checks for any missing content ranges when assembling the archive, if missing content ranges are found, Amazon Glacier returns an error and the operation fails.

Complete Multipart Upload is an idempotent operation. After your first successful complete multipart upload, if you call the operation again within a short period, the operation will succeed and return the same archive ID. This is useful in the event you experience a network issue that causes an aborted connection or receive a 500 server error, in which case you can repeat your Complete Multipart Upload request and get the same archive ID without creating duplicate archives. Note, however, that after the multipart upload completes, you cannot call the List Parts operation and the multipart upload will not appear in List Multipart Uploads response, even if idempotent complete is possible.

An AWS account has full permission to perform all operations (actions). However, AWS Identity and Access Management (IAM) users don't have any permissions by default. You must grant them explicit permission to perform specific actions. For more information, see Access Control Using AWS Identity and Access Management (IAM).

For conceptual information and underlying REST API, see Uploading Large Archives in Parts (Multipart Upload) and Complete Multipart Upload in the Amazon Glacier Developer Guide.

Inheritance: AmazonGlacierRequest
示例#1
0
        /// <summary>
        /// Initiates the asynchronous execution of the CompleteMultipartUpload operation.
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the CompleteMultipartUpload 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<CompleteMultipartUploadResponse> CompleteMultipartUploadAsync(CompleteMultipartUploadRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new CompleteMultipartUploadRequestMarshaller();
            var unmarshaller = CompleteMultipartUploadResponseUnmarshaller.Instance;

            return InvokeAsync<CompleteMultipartUploadRequest,CompleteMultipartUploadResponse>(request, marshaller, 
                unmarshaller, cancellationToken);
        }
示例#2
0
        /// <summary>
        /// Initiates the asynchronous execution of the CompleteMultipartUpload operation.
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the CompleteMultipartUpload operation on AmazonGlacierClient.</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 EndCompleteMultipartUpload
        ///         operation.</returns>
        public IAsyncResult BeginCompleteMultipartUpload(CompleteMultipartUploadRequest request, AsyncCallback callback, object state)
        {
            var marshaller = new CompleteMultipartUploadRequestMarshaller();
            var unmarshaller = CompleteMultipartUploadResponseUnmarshaller.Instance;

            return BeginInvoke<CompleteMultipartUploadRequest>(request, marshaller, unmarshaller,
                callback, state);
        }
示例#3
0
        internal CompleteMultipartUploadResponse CompleteMultipartUpload(CompleteMultipartUploadRequest request)
        {
            var marshaller = new CompleteMultipartUploadRequestMarshaller();
            var unmarshaller = CompleteMultipartUploadResponseUnmarshaller.Instance;

            return Invoke<CompleteMultipartUploadRequest,CompleteMultipartUploadResponse>(request, marshaller, unmarshaller);
        }
示例#4
0
        /// <summary>
        /// <para>You call this operation to inform Amazon Glacier that all the archive parts have been uploaded and that Amazon Glacier can now
        /// assemble the archive from the uploaded parts. After assembling and saving the archive to the vault, Amazon Glacier returns the URI path of
        /// the newly created archive resource. Using the URI path, you can then access the archive. After you upload an archive, you should save the
        /// archive ID returned to retrieve the archive at a later point. You can also get the vault inventory to obtain a list of archive IDs in a
        /// vault. For more information, see InitiateJob.</para> <para>In the request, you must include the computed SHA256 tree hash of the entire
        /// archive you have uploaded. For information about computing a SHA256 tree hash, see <a href="http://docs.aws.amazon.com/amazonglacier/latest/dev/checksum-calculations.html">Computing Checksums</a> . On the server side, Amazon
        /// Glacier also constructs the SHA256 tree hash of the assembled archive. If the values match, Amazon Glacier saves the archive to the vault;
        /// otherwise, it returns an error, and the operation fails. The ListParts operation returns a list of parts uploaded for a specific multipart
        /// upload. It includes checksum information for each uploaded part that can be used to debug a bad checksum issue.</para> <para>Additionally,
        /// Amazon Glacier also checks for any missing content ranges when assembling the archive, if missing content ranges are found, Amazon Glacier
        /// returns an error and the operation fails. </para> <para>Complete Multipart Upload is an idempotent operation. After your first successful
        /// complete multipart upload, if you call the operation again within a short period, the operation will succeed and return the same archive ID.
        /// This is useful in the event you experience a network issue that causes an aborted connection or receive a 500 server error, in which case
        /// you can repeat your Complete Multipart Upload request and get the same archive ID without creating duplicate archives. Note, however, that
        /// after the multipart upload completes, you cannot call the List Parts operation and the multipart upload will not appear in List Multipart
        /// Uploads response, even if idempotent complete is possible.</para> <para>An AWS account has full permission to perform all operations
        /// (actions). However, AWS Identity and Access Management (IAM) users don't have any permissions by default. You must grant them explicit
        /// permission to perform specific actions. For more information, see <a href="http://docs.aws.amazon.com/amazonglacier/latest/dev/using-iam-with-amazon-glacier.html">Access Control Using AWS Identity and Access
        /// Management (IAM)</a> .</para> <para> For conceptual information and underlying REST API, go to <a href="http://docs.aws.amazon.com/amazonglacier/latest/dev/uploading-archive-mpu.html">Uploading Large Archives in Parts (Multipart
        /// Upload)</a> and <a href="http://docs.aws.amazon.com/amazonglacier/latest/dev/api-multipart-complete-upload.html">Complete Multipart
        /// Upload</a> in the <i>Amazon Glacier Developer Guide</i> .
        /// </para>
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the CompleteMultipartUpload service method on
        /// AmazonGlacier.</param>
        /// 
        /// <returns>The response from the CompleteMultipartUpload service method, as returned by AmazonGlacier.</returns>
        /// 
        /// <exception cref="T:Amazon.Glacier.Model.ResourceNotFoundException" />
        /// <exception cref="T:Amazon.Glacier.Model.MissingParameterValueException" />
        /// <exception cref="T:Amazon.Glacier.Model.ServiceUnavailableException" />
        /// <exception cref="T:Amazon.Glacier.Model.InvalidParameterValueException" />
		public CompleteMultipartUploadResponse CompleteMultipartUpload(CompleteMultipartUploadRequest request)
        {
            var task = CompleteMultipartUploadAsync(request);
            try
            {
                return task.Result;
            }
            catch(AggregateException e)
            {
                ExceptionDispatchInfo.Capture(e.InnerException).Throw();
                return null;
            }
        }
示例#5
0
        /// <summary>
        /// Initiates the asynchronous execution of the CompleteMultipartUpload operation.
        /// <seealso cref="Amazon.Glacier.IAmazonGlacier.CompleteMultipartUpload"/>
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the CompleteMultipartUpload 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<CompleteMultipartUploadResponse> CompleteMultipartUploadAsync(CompleteMultipartUploadRequest request, CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new CompleteMultipartUploadRequestMarshaller();
            var unmarshaller = CompleteMultipartUploadResponseUnmarshaller.GetInstance();
            return Invoke<IRequest, CompleteMultipartUploadRequest, CompleteMultipartUploadResponse>(request, marshaller, unmarshaller, signer, cancellationToken);
        }
示例#6
0
        public string EndMultiPartUpload(long archiveSize, string checksum, string uploadId)
        {
            CompleteMultipartUploadRequest request = new CompleteMultipartUploadRequest()
            {
                ArchiveSize = archiveSize.ToString(),
                Checksum = checksum,
                UploadId = uploadId,
                VaultName = _vault
            };

            CompleteMultipartUploadResponse response = _amazonGlacierClient.CompleteMultipartUpload(request);
            return response.CompleteMultipartUploadResult.ArchiveId;
        }
        internal override void Execute()
        {
            FileInfo fileInfo = new FileInfo(filePath);
            FileStream fileStream = File.OpenRead(filePath);
            string uploadId = null;
            try
            {
                this.currentUploadProgressArgs = new StreamTransferProgressArgs(0, 0, fileInfo.Length);

                long partSize = CalculatePartSize(fileInfo.Length);
                InitiateMultipartUploadRequest initiateRequest = new InitiateMultipartUploadRequest
                {
                    AccountId = this.options.AccountId,
                    ArchiveDescription = archiveDescription,
                    VaultName = vaultName,
                    PartSize = partSize
                };
                initiateRequest.BeforeRequestEvent += new UserAgentPostFix("MultiUpload").UserAgentRequestEventHandlerSync;
                InitiateMultipartUploadResult initiateResult = this.manager.GlacierClient.InitiateMultipartUpload(initiateRequest).InitiateMultipartUploadResult;

                uploadId = initiateResult.UploadId;

                List<string> partTreeHashs = new List<string>();
                long currentPosition = 0;
                while (currentPosition < fileInfo.Length)
                {
                    long length = partSize;
                    if (currentPosition + partSize > fileInfo.Length)
                    {
                        length = fileInfo.Length - currentPosition;
                    }

                    PartStreamWrapper partStream = new PartStreamWrapper(fileStream, length);

                    string checksum = TreeHashGenerator.CalculateTreeHash(partStream);
                    partTreeHashs.Add(checksum);

                    UploadMultipartPartRequest uploadRequest = new UploadMultipartPartRequest
                    {
                        AccountId=this.options.AccountId,
                        Checksum=checksum,
                        Body=partStream,
                        Range = ("bytes " + currentPosition + "-" + (currentPosition + length - 1) + "/*"),
                        UploadId=uploadId,
                        VaultName=vaultName
                    };
                    uploadRequest.StreamTransferProgress += this.ProgressCallback;
                    uploadRequest.BeforeRequestEvent += new UserAgentPostFix("MultiUpload").UserAgentRequestEventHandlerSync;

                    this.manager.GlacierClient.UploadMultipartPart(uploadRequest);
                    currentPosition += partSize;
                }

                string totalFileChecksum = TreeHashGenerator.CalculateTreeHash(partTreeHashs);
                string archiveSize = fileInfo.Length.ToString();
                CompleteMultipartUploadRequest compRequest = new CompleteMultipartUploadRequest
                {
                    AccountId=this.options.AccountId,
                    ArchiveSize=archiveSize,
                    VaultName=vaultName,
                    Checksum=totalFileChecksum,
                    UploadId=uploadId
                };
                compRequest.BeforeRequestEvent += new UserAgentPostFix("MultiUpload").UserAgentRequestEventHandlerSync;
                CompleteMultipartUploadResult completeMultipartUploadResult = this.manager.GlacierClient.CompleteMultipartUpload(compRequest).CompleteMultipartUploadResult;

                string archiveId = completeMultipartUploadResult.ArchiveId;
                this.UploadResult = new UploadResult(archiveId, totalFileChecksum);
            }
            catch (Exception)
            {
                // If we got an unrecoverable then abort the upload.
                if (!string.IsNullOrEmpty(uploadId))
                {
                    AbortMultipartUploadRequest abortRequest = new AbortMultipartUploadRequest()
                    {
                        AccountId = this.options.AccountId,
                        VaultName = this.vaultName,
                        UploadId = uploadId
                    };
                    abortRequest.BeforeRequestEvent += new UserAgentPostFix("MultiUpload").UserAgentRequestEventHandlerSync;
                    this.manager.GlacierClient.AbortMultipartUpload(abortRequest);
                }

                throw;
            }
            finally
            {
                try { fileStream.Close(); }
                catch (Exception) { }
            }
        }
 /// <summary>
 /// Initiates the asynchronous execution of the CompleteMultipartUpload operation.
 /// <seealso cref="Amazon.Glacier.AmazonGlacier.CompleteMultipartUpload"/>
 /// </summary>
 /// 
 /// <param name="completeMultipartUploadRequest">Container for the necessary parameters to execute the CompleteMultipartUpload operation on
 ///          AmazonGlacier.</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
 ///         EndCompleteMultipartUpload operation.</returns>
 public IAsyncResult BeginCompleteMultipartUpload(CompleteMultipartUploadRequest completeMultipartUploadRequest, AsyncCallback callback, object state)
 {
     return invokeCompleteMultipartUpload(completeMultipartUploadRequest, callback, state, false);
 }
 /// <summary>
 /// <para>You call this operation to inform Amazon Glacier that all the archive parts have been uploaded and that Amazon Glacier can now
 /// assemble the archive from the uploaded parts. After assembling and saving the archive to the vault, Amazon Glacier returns the URI path of
 /// the newly created archive resource. Using the URI path, you can then access the archive. After you upload an archive, you should save the
 /// archive ID returned to retrieve the archive at a later point. You can also get the vault inventory to obtain a list of archive IDs in a
 /// vault. For more information, see InitiateJob.</para> <para>In the request, you must include the computed SHA256 tree hash of the entire
 /// archive you have uploaded. For information about computing a SHA256 tree hash, see Computing Checksums. On the server side, Amazon Glacier
 /// also constructs the SHA256 tree hash of the assembled archive. If the values match, Amazon Glacier saves the archive to the vault;
 /// otherwise, it returns an error, and the operation fails. The ListParts operation returns a list of parts uploaded for a specific multipart
 /// upload. It includes checksum information for each uploaded part that can be used to debug a bad checksum issue.</para> <para>Additionally,
 /// Amazon Glacier also checks for any missing content ranges when assembling the archive, if missing content ranges are found, Amazon Glacier
 /// returns an error and the operation fails. </para> <para>Complete Multipart Upload is an idempotent operation. After your first successful
 /// complete multipart upload, if you call the operation again within a short period, the operation will succeed and return the same archive ID.
 /// This is useful in the event you experience a network issue that causes an aborted connection or receive a 500 server error, in which case
 /// you can repeat your Complete Multipart Upload request and get the same archive ID without creating duplicate archives. Note, however, that
 /// after the multipart upload completes, you cannot call the List Parts operation and the multipart upload will not appear in List Multipart
 /// Uploads response, even if idempotent complete is possible.</para> <para>An AWS account has full permission to perform all operations
 /// (actions). However, AWS Identity and Access Management (IAM) users don't have any permissions by default. You must grant them explicit
 /// permission to perform specific actions. For more information, see Access Control Using AWS Identity and Access Management (IAM).</para>
 /// <para> For conceptual information and underlying REST API, go to Uploading Large Archives in Parts (Multipart Upload) and Complete Multipart
 /// Upload in the <i>Amazon Glacier Developer Guide</i> .
 /// </para>
 /// </summary>
 /// 
 /// <param name="completeMultipartUploadRequest">Container for the necessary parameters to execute the CompleteMultipartUpload service method on
 ///          AmazonGlacier.</param>
 /// 
 /// <returns>The response from the CompleteMultipartUpload service method, as returned by AmazonGlacier.</returns>
 /// 
 /// <exception cref="ResourceNotFoundException"/>
 /// <exception cref="MissingParameterValueException"/>
 /// <exception cref="ServiceUnavailableException"/>
 /// <exception cref="InvalidParameterValueException"/>
 public CompleteMultipartUploadResponse CompleteMultipartUpload(CompleteMultipartUploadRequest completeMultipartUploadRequest)
 {
     IAsyncResult asyncResult = invokeCompleteMultipartUpload(completeMultipartUploadRequest, null, null, true);
     return EndCompleteMultipartUpload(asyncResult);
 }
 IAsyncResult invokeCompleteMultipartUpload(CompleteMultipartUploadRequest completeMultipartUploadRequest, AsyncCallback callback, object state, bool synchronized)
 {
     IRequest irequest = new CompleteMultipartUploadRequestMarshaller().Marshall(completeMultipartUploadRequest);
     var unmarshaller = CompleteMultipartUploadResponseUnmarshaller.GetInstance();
     AsyncResult result = new AsyncResult(irequest, callback, state, synchronized, signer, unmarshaller);
     Invoke(result);
     return result;
 }
示例#11
0
        /// <summary>
        /// <para>You call this operation to inform Amazon Glacier that all the archive parts have been uploaded and that Amazon Glacier can now
        /// assemble the archive from the uploaded parts. After assembling and saving the archive to the vault, Amazon Glacier returns the URI path of
        /// the newly created archive resource. Using the URI path, you can then access the archive. After you upload an archive, you should save the
        /// archive ID returned to retrieve the archive at a later point. You can also get the vault inventory to obtain a list of archive IDs in a
        /// vault. For more information, see InitiateJob.</para> <para>In the request, you must include the computed SHA256 tree hash of the entire
        /// archive you have uploaded. For information about computing a SHA256 tree hash, see <a href="http://docs.aws.amazon.com/amazonglacier/latest/dev/checksum-calculations.html">Computing Checksums</a> . On the server side, Amazon
        /// Glacier also constructs the SHA256 tree hash of the assembled archive. If the values match, Amazon Glacier saves the archive to the vault;
        /// otherwise, it returns an error, and the operation fails. The ListParts operation returns a list of parts uploaded for a specific multipart
        /// upload. It includes checksum information for each uploaded part that can be used to debug a bad checksum issue.</para> <para>Additionally,
        /// Amazon Glacier also checks for any missing content ranges when assembling the archive, if missing content ranges are found, Amazon Glacier
        /// returns an error and the operation fails. </para> <para>Complete Multipart Upload is an idempotent operation. After your first successful
        /// complete multipart upload, if you call the operation again within a short period, the operation will succeed and return the same archive ID.
        /// This is useful in the event you experience a network issue that causes an aborted connection or receive a 500 server error, in which case
        /// you can repeat your Complete Multipart Upload request and get the same archive ID without creating duplicate archives. Note, however, that
        /// after the multipart upload completes, you cannot call the List Parts operation and the multipart upload will not appear in List Multipart
        /// Uploads response, even if idempotent complete is possible.</para> <para>An AWS account has full permission to perform all operations
        /// (actions). However, AWS Identity and Access Management (IAM) users don't have any permissions by default. You must grant them explicit
        /// permission to perform specific actions. For more information, see <a href="http://docs.aws.amazon.com/amazonglacier/latest/dev/using-iam-with-amazon-glacier.html">Access Control Using AWS Identity and Access
        /// Management (IAM)</a> .</para> <para> For conceptual information and underlying REST API, go to <a href="http://docs.aws.amazon.com/amazonglacier/latest/dev/uploading-archive-mpu.html">Uploading Large Archives in Parts (Multipart
        /// Upload)</a> and <a href="http://docs.aws.amazon.com/amazonglacier/latest/dev/api-multipart-complete-upload.html">Complete Multipart
        /// Upload</a> in the <i>Amazon Glacier Developer Guide</i> .
        /// </para>
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the CompleteMultipartUpload service method on
        /// AmazonGlacier.</param>
        /// 
        /// <returns>The response from the CompleteMultipartUpload service method, as returned by AmazonGlacier.</returns>
        /// 
        /// <exception cref="T:Amazon.Glacier.Model.ResourceNotFoundException" />
        /// <exception cref="T:Amazon.Glacier.Model.MissingParameterValueException" />
        /// <exception cref="T:Amazon.Glacier.Model.ServiceUnavailableException" />
        /// <exception cref="T:Amazon.Glacier.Model.InvalidParameterValueException" />
		public CompleteMultipartUploadResponse CompleteMultipartUpload(CompleteMultipartUploadRequest request)
        {
            var task = CompleteMultipartUploadAsync(request);
            try
            {
                return task.Result;
            }
            catch(AggregateException e)
            {
                throw e.InnerException;
            }
        }
        /// <summary>
        /// Initiates the asynchronous execution of the CompleteMultipartUpload operation.
        /// <seealso cref="Amazon.Glacier.IAmazonGlacier.CompleteMultipartUpload"/>
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the CompleteMultipartUpload 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 async Task<CompleteMultipartUploadResponse> CompleteMultipartUploadAsync(CompleteMultipartUploadRequest request, CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new CompleteMultipartUploadRequestMarshaller();
            var unmarshaller = CompleteMultipartUploadResponseUnmarshaller.GetInstance();
            var response = await Invoke<IRequest, CompleteMultipartUploadRequest, CompleteMultipartUploadResponse>(request, marshaller, unmarshaller, signer, cancellationToken)
                .ConfigureAwait(continueOnCapturedContext: false);
            return response;
        }
        internal override async Task ExecuteAsync()
        {
            FileInfo fileInfo = new FileInfo(filePath);
            FileStream fileStream = File.OpenRead(filePath);
            string uploadId = null;
            try
            {
                this.currentUploadProgressArgs = new StreamTransferProgressArgs(0, 0, fileInfo.Length);

                long partSize = CalculatePartSize(fileInfo.Length);
                InitiateMultipartUploadRequest initiateRequest = new InitiateMultipartUploadRequest()
                {
                    AccountId = this.options.AccountId,
                    ArchiveDescription = archiveDescription,
                    VaultName = vaultName,
                    PartSize = partSize
                };

                ((Amazon.Runtime.Internal.IAmazonWebServiceRequest)initiateRequest).AddBeforeRequestHandler(new ArchiveTransferManager.UserAgentPostFix("MultiUpload").UserAgentRequestEventHandlerSync);
                InitiateMultipartUploadResponse initiateResponse = await this.manager.GlacierClient.InitiateMultipartUploadAsync(initiateRequest).ConfigureAwait(false);


                uploadId = initiateResponse.UploadId;

                List<string> partTreeHashs = new List<string>();
                long currentPosition = 0;
                while (currentPosition < fileInfo.Length)
                {
                    long length = partSize;
                    if (currentPosition + partSize > fileInfo.Length)
                    {
                        length = fileInfo.Length - currentPosition;
                    }

                    Stream partStream = new PartialWrapperStream(fileStream, length);

                    string checksum = TreeHashGenerator.CalculateTreeHash(partStream);
                    partTreeHashs.Add(checksum);

                    UploadMultipartPartRequest uploadRequest = new UploadMultipartPartRequest()
                    {
                        AccountId = this.options.AccountId,
                        Checksum = checksum,
                        Range = "bytes " + currentPosition + "-" + (currentPosition + length - 1) + "/*",
                        UploadId = uploadId,
                        VaultName = vaultName,
                        Body = partStream
                    };

                    uploadRequest.StreamTransferProgress += this.ProgressCallback;
                    ((Amazon.Runtime.Internal.IAmazonWebServiceRequest)uploadRequest).AddBeforeRequestHandler(new ArchiveTransferManager.UserAgentPostFix("MultiUpload").UserAgentRequestEventHandlerSync);

                    await this.manager.GlacierClient.UploadMultipartPartAsync(uploadRequest).ConfigureAwait(false);
                    currentPosition += partSize;
                }

                string totalFileChecksum = TreeHashGenerator.CalculateTreeHash(partTreeHashs);
                string archiveSize = fileInfo.Length.ToString(CultureInfo.InvariantCulture);
                CompleteMultipartUploadRequest compRequest = new CompleteMultipartUploadRequest()
                {
                    AccountId = this.options.AccountId,
                    ArchiveSize = archiveSize,
                    VaultName = vaultName,
                    Checksum = totalFileChecksum,
                    UploadId = uploadId
                };

                ((Amazon.Runtime.Internal.IAmazonWebServiceRequest)compRequest).AddBeforeRequestHandler(new ArchiveTransferManager.UserAgentPostFix("MultiUpload").UserAgentRequestEventHandlerSync);
                CompleteMultipartUploadResponse completeMultipartUploadResponse = await this.manager.GlacierClient.CompleteMultipartUploadAsync(compRequest).ConfigureAwait(false);

                string archiveId = completeMultipartUploadResponse.ArchiveId;
                this.UploadResult = new UploadResult(archiveId, totalFileChecksum);
            }
            catch (Exception)
            {
                // If we got an unrecoverable then abort the upload.
                if (!string.IsNullOrEmpty(uploadId))
                {
                    AbortMultipartUploadRequest abortRequest = new AbortMultipartUploadRequest()
                    {
                        AccountId = this.options.AccountId,
                        VaultName = this.vaultName,
                        UploadId = uploadId
                    };
                    ((Amazon.Runtime.Internal.IAmazonWebServiceRequest)abortRequest).AddBeforeRequestHandler(new ArchiveTransferManager.UserAgentPostFix("MultiUpload").UserAgentRequestEventHandlerSync);
                    this.manager.GlacierClient.AbortMultipartUploadAsync(abortRequest).Wait();
                }

                throw;
            }
            finally
            {
                try { fileStream.Dispose(); }
                catch (Exception) { }
            }
        }
示例#14
0
        static string CompleteMPU(string uploadID, AmazonGlacier client, List<string> partChecksumList)
        {
            long fileLength = new FileInfo(BackupFilePath).Length;
            var completeMPUrequest = new CompleteMultipartUploadRequest()
            {
                UploadId = uploadID,
                ArchiveSize = fileLength.ToString(),
                Checksum = TreeHashGenerator.CalculateTreeHash(partChecksumList),
                VaultName = VaultName
            };

            var completeMPUresponse = client.CompleteMultipartUpload(completeMPUrequest);
            return completeMPUresponse.CompleteMultipartUploadResult.ArchiveId;
        }