/// <summary> /// Initiates the asynchronous execution of the InitiateMultipartUpload operation. /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the InitiateMultipartUpload 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<InitiateMultipartUploadResponse> InitiateMultipartUploadAsync(InitiateMultipartUploadRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken)) { var marshaller = new InitiateMultipartUploadRequestMarshaller(); var unmarshaller = InitiateMultipartUploadResponseUnmarshaller.Instance; return InvokeAsync<InitiateMultipartUploadRequest,InitiateMultipartUploadResponse>(request, marshaller, unmarshaller, cancellationToken); }
/// <summary> /// Initiates the asynchronous execution of the InitiateMultipartUpload operation. /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the InitiateMultipartUpload 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 EndInitiateMultipartUpload /// operation.</returns> public IAsyncResult BeginInitiateMultipartUpload(InitiateMultipartUploadRequest request, AsyncCallback callback, object state) { var marshaller = new InitiateMultipartUploadRequestMarshaller(); var unmarshaller = InitiateMultipartUploadResponseUnmarshaller.Instance; return BeginInvoke<InitiateMultipartUploadRequest>(request, marshaller, unmarshaller, callback, state); }
internal InitiateMultipartUploadResponse InitiateMultipartUpload(InitiateMultipartUploadRequest request) { var marshaller = new InitiateMultipartUploadRequestMarshaller(); var unmarshaller = InitiateMultipartUploadResponseUnmarshaller.Instance; return Invoke<InitiateMultipartUploadRequest,InitiateMultipartUploadResponse>(request, marshaller, unmarshaller); }
/// <summary> /// <para>This operation initiates a multipart upload. Amazon Glacier creates a multipart upload resource and returns its ID in the response. /// The multipart upload ID is used in subsequent requests to upload parts of an archive (see UploadMultipartPart).</para> <para>When you /// initiate a multipart upload, you specify the part size in number of bytes. The part size must be a megabyte (1024 KB) multiplied by a power /// of 2-for example, 1048576 (1 MB), 2097152 (2 MB), 4194304 (4 MB), 8388608 (8 MB), and so on. The minimum allowable part size is 1 MB, and /// the maximum is 4 GB.</para> <para>Every part you upload to this resource (see UploadMultipartPart), except the last one, must have the same /// size. The last one can be the same size or smaller. For example, suppose you want to upload a 16.2 MB file. If you initiate the multipart /// upload with a part size of 4 MB, you will upload four parts of 4 MB each and one part of 0.2 MB. </para> <para><b>NOTE:</b> You don't need /// to know the size of the archive when you start a multipart upload because Amazon Glacier does not require you to specify the overall archive /// size. </para> <para>After you complete the multipart upload, Amazon Glacier removes the multipart upload resource referenced by the ID. /// Amazon Glacier also removes the multipart upload resource if you cancel the multipart upload or it may be removed if there is no activity /// for a period of 24 hours.</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-initiate-upload.html">Initiate Multipart /// Upload</a> in the <i>Amazon Glacier Developer Guide</i> .</para> /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the InitiateMultipartUpload service method on /// AmazonGlacier.</param> /// /// <returns>The response from the InitiateMultipartUpload 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 InitiateMultipartUploadResponse InitiateMultipartUpload(InitiateMultipartUploadRequest request) { var task = InitiateMultipartUploadAsync(request); try { return task.Result; } catch(AggregateException e) { ExceptionDispatchInfo.Capture(e.InnerException).Throw(); return null; } }
/// <summary> /// Initiates the asynchronous execution of the InitiateMultipartUpload operation. /// <seealso cref="Amazon.Glacier.IAmazonGlacier.InitiateMultipartUpload"/> /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the InitiateMultipartUpload 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<InitiateMultipartUploadResponse> InitiateMultipartUploadAsync(InitiateMultipartUploadRequest request, CancellationToken cancellationToken = default(CancellationToken)) { var marshaller = new InitiateMultipartUploadRequestMarshaller(); var unmarshaller = InitiateMultipartUploadResponseUnmarshaller.GetInstance(); return Invoke<IRequest, InitiateMultipartUploadRequest, InitiateMultipartUploadResponse>(request, marshaller, unmarshaller, signer, cancellationToken); }
public string InitiateMultiPartUpload(int packetSize) { InitiateMultipartUploadRequest initiateRequest = new InitiateMultipartUploadRequest() { ArchiveDescription = _archive, PartSize = packetSize, VaultName = _vault }; InitiateMultipartUploadResponse response = _amazonGlacierClient.InitiateMultipartUpload(initiateRequest); return response.InitiateMultipartUploadResult.UploadId; }
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) { } } }
IAsyncResult invokeInitiateMultipartUpload(InitiateMultipartUploadRequest initiateMultipartUploadRequest, AsyncCallback callback, object state, bool synchronized) { IRequest irequest = new InitiateMultipartUploadRequestMarshaller().Marshall(initiateMultipartUploadRequest); var unmarshaller = InitiateMultipartUploadResponseUnmarshaller.GetInstance(); AsyncResult result = new AsyncResult(irequest, callback, state, synchronized, signer, unmarshaller); Invoke(result); return result; }
/// <summary> /// Initiates the asynchronous execution of the InitiateMultipartUpload operation. /// <seealso cref="Amazon.Glacier.AmazonGlacier.InitiateMultipartUpload"/> /// </summary> /// /// <param name="initiateMultipartUploadRequest">Container for the necessary parameters to execute the InitiateMultipartUpload 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 /// EndInitiateMultipartUpload operation.</returns> public IAsyncResult BeginInitiateMultipartUpload(InitiateMultipartUploadRequest initiateMultipartUploadRequest, AsyncCallback callback, object state) { return invokeInitiateMultipartUpload(initiateMultipartUploadRequest, callback, state, false); }
/// <summary> /// <para>This operation initiates a multipart upload. Amazon Glacier creates a multipart upload resource and returns its ID in the response. /// The multipart upload ID is used in subsequent requests to upload parts of an archive (see UploadMultipartPart).</para> <para>When you /// initiate a multipart upload, you specify the part size in number of bytes. The part size must be a megabyte (1024 KB) multiplied by a power /// of 2-for example, 1048576 (1 MB), 2097152 (2 MB), 4194304 (4 MB), 8388608 (8 MB), and so on. The minimum allowable part size is 1 MB, and /// the maximum is 4 GB.</para> <para>Every part you upload to this resource (see UploadMultipartPart), except the last one, must have the same /// size. The last one can be the same size or smaller. For example, suppose you want to upload a 16.2 MB file. If you initiate the multipart /// upload with a part size of 4 MB, you will upload four parts of 4 MB each and one part of 0.2 MB. </para> <para><b>NOTE:</b> You don't need /// to know the size of the archive when you start a multipart upload because Amazon Glacier does not require you to specify the overall archive /// size. </para> <para>After you complete the multipart upload, Amazon Glacier removes the multipart upload resource referenced by the ID. /// Amazon Glacier also removes the multipart upload resource if you cancel the multipart upload or it may be removed if there is no activity /// for a period of 24 hours.</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 Initiate Multipart Upload in the <i>Amazon Glacier /// Developer Guide</i> .</para> /// </summary> /// /// <param name="initiateMultipartUploadRequest">Container for the necessary parameters to execute the InitiateMultipartUpload service method on /// AmazonGlacier.</param> /// /// <returns>The response from the InitiateMultipartUpload service method, as returned by AmazonGlacier.</returns> /// /// <exception cref="ResourceNotFoundException"/> /// <exception cref="MissingParameterValueException"/> /// <exception cref="ServiceUnavailableException"/> /// <exception cref="InvalidParameterValueException"/> public InitiateMultipartUploadResponse InitiateMultipartUpload(InitiateMultipartUploadRequest initiateMultipartUploadRequest) { IAsyncResult asyncResult = invokeInitiateMultipartUpload(initiateMultipartUploadRequest, null, null, true); return EndInitiateMultipartUpload(asyncResult); }
/// <summary> /// <para>This operation initiates a multipart upload. Amazon Glacier creates a multipart upload resource and returns its ID in the response. /// The multipart upload ID is used in subsequent requests to upload parts of an archive (see UploadMultipartPart).</para> <para>When you /// initiate a multipart upload, you specify the part size in number of bytes. The part size must be a megabyte (1024 KB) multiplied by a power /// of 2-for example, 1048576 (1 MB), 2097152 (2 MB), 4194304 (4 MB), 8388608 (8 MB), and so on. The minimum allowable part size is 1 MB, and /// the maximum is 4 GB.</para> <para>Every part you upload to this resource (see UploadMultipartPart), except the last one, must have the same /// size. The last one can be the same size or smaller. For example, suppose you want to upload a 16.2 MB file. If you initiate the multipart /// upload with a part size of 4 MB, you will upload four parts of 4 MB each and one part of 0.2 MB. </para> <para><b>NOTE:</b> You don't need /// to know the size of the archive when you start a multipart upload because Amazon Glacier does not require you to specify the overall archive /// size. </para> <para>After you complete the multipart upload, Amazon Glacier removes the multipart upload resource referenced by the ID. /// Amazon Glacier also removes the multipart upload resource if you cancel the multipart upload or it may be removed if there is no activity /// for a period of 24 hours.</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-initiate-upload.html">Initiate Multipart /// Upload</a> in the <i>Amazon Glacier Developer Guide</i> .</para> /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the InitiateMultipartUpload service method on /// AmazonGlacier.</param> /// /// <returns>The response from the InitiateMultipartUpload 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 InitiateMultipartUploadResponse InitiateMultipartUpload(InitiateMultipartUploadRequest request) { var task = InitiateMultipartUploadAsync(request); try { return task.Result; } catch(AggregateException e) { throw e.InnerException; } }
/// <summary> /// Initiates the asynchronous execution of the InitiateMultipartUpload operation. /// <seealso cref="Amazon.Glacier.IAmazonGlacier.InitiateMultipartUpload"/> /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the InitiateMultipartUpload 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<InitiateMultipartUploadResponse> InitiateMultipartUploadAsync(InitiateMultipartUploadRequest request, CancellationToken cancellationToken = default(CancellationToken)) { var marshaller = new InitiateMultipartUploadRequestMarshaller(); var unmarshaller = InitiateMultipartUploadResponseUnmarshaller.GetInstance(); var response = await Invoke<IRequest, InitiateMultipartUploadRequest, InitiateMultipartUploadResponse>(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) { } } }
static string InitiateMultipartUpload(AmazonGlacier client) { var initiateMPUrequest = new InitiateMultipartUploadRequest() { VaultName = VaultName, PartSize = partSize, ArchiveDescription = ArchiveDescription }; var initiateMPUresponse = client.InitiateMultipartUpload(initiateMPUrequest); return initiateMPUresponse.InitiateMultipartUploadResult.UploadId; }