internal override async Task ExecuteAsync() { FileStream input = File.OpenRead(filePath); string checksum = TreeHashGenerator.CalculateTreeHash(input); try { UploadArchiveRequest uploadRequest = new UploadArchiveRequest() { AccountId = this.options.AccountId, ArchiveDescription = archiveDescription, VaultName = vaultName, Checksum = checksum, Body = input }; uploadRequest.StreamTransferProgress += this.ProgressCallback; ((Amazon.Runtime.Internal.IAmazonWebServiceRequest)uploadRequest).AddBeforeRequestHandler(new ArchiveTransferManager.UserAgentPostFix("SingleUpload").UserAgentRequestEventHandlerSync); UploadArchiveResponse uploadArchivResponse = await this.manager.GlacierClient.UploadArchiveAsync(uploadRequest).ConfigureAwait(false); string archiveId = uploadArchivResponse.ArchiveId; this.UploadResult = new UploadResult(archiveId, checksum); } finally { try { input.Dispose(); } catch (Exception) { } } }
internal override void Execute() { FileInfo fi = new FileInfo(filePath); FileStream input = File.OpenRead(filePath); string checksum = TreeHashGenerator.CalculateTreeHash(input); try { UploadArchiveRequest uploadRequest = new UploadArchiveRequest() .WithAccountId(this.options.AccountId) .WithArchiveDescription(archiveDescription) .WithVaultName(vaultName) .WithChecksum(checksum) .WithBody(input); uploadRequest.StreamTransferProgress += this.ProgressCallback; uploadRequest.BeforeRequestEvent += new UserAgentPostFix("SingleUpload").UserAgentRequestEventHandlerSync; UploadArchiveResult uploadArchiveResult = this.manager.GlacierClient.UploadArchive(uploadRequest).UploadArchiveResult; string archiveId = uploadArchiveResult.ArchiveId; this.UploadResult = new UploadResult(archiveId, checksum); } finally { try { input.Close(); } catch (Exception) { } } }
internal override void Execute() { FileStream input = File.OpenRead(filePath); string checksum = TreeHashGenerator.CalculateTreeHash(input); try { UploadArchiveRequest uploadRequest = new UploadArchiveRequest() { AccountId = this.options.AccountId, ArchiveDescription = archiveDescription, VaultName = vaultName, Checksum = checksum, Body = input }; uploadRequest.StreamTransferProgress += this.ProgressCallback; uploadRequest.BeforeRequestEvent += new UserAgentPostFix("SingleUpload").UserAgentRequestEventHandlerSync; UploadArchiveResponse uploadArchivResponse = this.manager.GlacierClient.UploadArchive(uploadRequest); string archiveId = uploadArchivResponse.ArchiveId; this.UploadResult = new UploadResult(archiveId, checksum); } finally { try { input.Close(); } catch (Exception) { } } }
/// <summary> /// Initiates the asynchronous execution of the UploadArchive operation. /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the UploadArchive 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<UploadArchiveResponse> UploadArchiveAsync(UploadArchiveRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken)) { var marshaller = new UploadArchiveRequestMarshaller(); var unmarshaller = UploadArchiveResponseUnmarshaller.Instance; return InvokeAsync<UploadArchiveRequest,UploadArchiveResponse>(request, marshaller, unmarshaller, cancellationToken); }
internal UploadArchiveResponse UploadArchive(UploadArchiveRequest request) { var marshaller = new UploadArchiveRequestMarshaller(); var unmarshaller = UploadArchiveResponseUnmarshaller.Instance; return Invoke<UploadArchiveRequest,UploadArchiveResponse>(request, marshaller, unmarshaller); }
/// <summary> /// Initiates the asynchronous execution of the UploadArchive operation. /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the UploadArchive 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 EndUploadArchive /// operation.</returns> public IAsyncResult BeginUploadArchive(UploadArchiveRequest request, AsyncCallback callback, object state) { var marshaller = new UploadArchiveRequestMarshaller(); var unmarshaller = UploadArchiveResponseUnmarshaller.Instance; return BeginInvoke<UploadArchiveRequest>(request, marshaller, unmarshaller, callback, state); }
/// <summary> /// Initiates the asynchronous execution of the UploadArchive operation. /// <seealso cref="Amazon.Glacier.IAmazonGlacier.UploadArchive"/> /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the UploadArchive 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<UploadArchiveResponse> UploadArchiveAsync(UploadArchiveRequest request, CancellationToken cancellationToken = default(CancellationToken)) { var marshaller = new UploadArchiveRequestMarshaller(); var unmarshaller = UploadArchiveResponseUnmarshaller.GetInstance(); return Invoke<IRequest, UploadArchiveRequest, UploadArchiveResponse>(request, marshaller, unmarshaller, signer, cancellationToken); }
/// <summary> /// <para>This operation adds an archive to a vault. This is a synchronous operation, and for a successful upload, your data is durably /// persisted. Amazon Glacier returns the archive ID in the <c>x-amz-archive-id</c> header of the response. </para> <para>You must use the /// archive ID to access your data in Amazon Glacier. After you upload an archive, you should save the archive ID returned so that you can /// retrieve or delete the archive later. Besides saving the archive ID, you can also index it and give it a friendly name to allow for better /// searching. You can also use the optional archive description field to specify how the archive is referred to in an external index of /// archives, such as you might create in Amazon DynamoDB. You can also get the vault inventory to obtain a list of archive IDs in a vault. For /// more information, see InitiateJob. </para> <para>You must provide a SHA256 tree hash of the data you are uploading. 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> . </para> <para>You can optionally specify an archive description of up to 1,024 printable ASCII characters. You can get the /// archive description when you either retrieve the archive or get the vault inventory. For more information, see InitiateJob. Amazon Glacier /// does not interpret the description in any way. An archive description does not need to be unique. You cannot use the description to retrieve /// or sort the archive list. </para> <para>Archives are immutable. After you upload an archive, you cannot edit the archive or its description. /// </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-an-archive.html">Uploading an Archive in Amazon Glacier</a> and <a href="http://docs.aws.amazon.com/amazonglacier/latest/dev/api-archive-post.html">Upload Archive</a> in the <i>Amazon Glacier Developer /// Guide</i> . /// </para> /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the UploadArchive service method on /// AmazonGlacier.</param> /// /// <returns>The response from the UploadArchive 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.RequestTimeoutException" /> /// <exception cref="T:Amazon.Glacier.Model.ServiceUnavailableException" /> /// <exception cref="T:Amazon.Glacier.Model.InvalidParameterValueException" /> public UploadArchiveResponse UploadArchive(UploadArchiveRequest request) { var task = UploadArchiveAsync(request); try { return task.Result; } catch(AggregateException e) { ExceptionDispatchInfo.Capture(e.InnerException).Throw(); return null; } }
/// <summary> /// Initiates the asynchronous execution of the UploadArchive operation. /// <seealso cref="Amazon.Glacier.AmazonGlacier.UploadArchive"/> /// </summary> /// /// <param name="uploadArchiveRequest">Container for the necessary parameters to execute the UploadArchive 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 EndUploadArchive /// operation.</returns> public IAsyncResult BeginUploadArchive(UploadArchiveRequest uploadArchiveRequest, AsyncCallback callback, object state) { return invokeUploadArchive(uploadArchiveRequest, callback, state, false); }
IAsyncResult invokeUploadArchive(UploadArchiveRequest uploadArchiveRequest, AsyncCallback callback, object state, bool synchronized) { IRequest irequest = new UploadArchiveRequestMarshaller().Marshall(uploadArchiveRequest); var unmarshaller = UploadArchiveResponseUnmarshaller.GetInstance(); AsyncResult result = new AsyncResult(irequest, callback, state, synchronized, signer, unmarshaller); Invoke(result); return result; }
/// <summary> /// <para>This operation adds an archive to a vault. This is a synchronous operation, and for a successful upload, your data is durably /// persisted. Amazon Glacier returns the archive ID in the <c>x-amz-archive-id</c> header of the response. </para> <para>You must use the /// archive ID to access your data in Amazon Glacier. After you upload an archive, you should save the archive ID returned so that you can /// retrieve or delete the archive later. Besides saving the archive ID, you can also index it and give it a friendly name to allow for better /// searching. You can also use the optional archive description field to specify how the archive is referred to in an external index of /// archives, such as you might create in Amazon DynamoDB. You can also get the vault inventory to obtain a list of archive IDs in a vault. For /// more information, see InitiateJob. </para> <para>You must provide a SHA256 tree hash of the data you are uploading. For information about /// computing a SHA256 tree hash, see Computing Checksums. </para> <para>You can optionally specify an archive description of up to 1,024 /// printable ASCII characters. You can get the archive description when you either retrieve the archive or get the vault inventory. For more /// information, see InitiateJob. Amazon Glacier does not interpret the description in any way. An archive description does not need to be /// unique. You cannot use the description to retrieve or sort the archive list. </para> <para>Archives are immutable. After you upload an /// archive, you cannot edit the archive or its description. </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 an Archive in Amazon Glacier and Upload Archive in the <i>Amazon /// Glacier Developer Guide</i> . /// </para> /// </summary> /// /// <param name="uploadArchiveRequest">Container for the necessary parameters to execute the UploadArchive service method on /// AmazonGlacier.</param> /// /// <returns>The response from the UploadArchive service method, as returned by AmazonGlacier.</returns> /// /// <exception cref="ResourceNotFoundException"/> /// <exception cref="MissingParameterValueException"/> /// <exception cref="RequestTimeoutException"/> /// <exception cref="ServiceUnavailableException"/> /// <exception cref="InvalidParameterValueException"/> public UploadArchiveResponse UploadArchive(UploadArchiveRequest uploadArchiveRequest) { IAsyncResult asyncResult = invokeUploadArchive(uploadArchiveRequest, null, null, true); return EndUploadArchive(asyncResult); }
/// <summary> /// <para>This operation adds an archive to a vault. This is a synchronous operation, and for a successful upload, your data is durably /// persisted. Amazon Glacier returns the archive ID in the <c>x-amz-archive-id</c> header of the response. </para> <para>You must use the /// archive ID to access your data in Amazon Glacier. After you upload an archive, you should save the archive ID returned so that you can /// retrieve or delete the archive later. Besides saving the archive ID, you can also index it and give it a friendly name to allow for better /// searching. You can also use the optional archive description field to specify how the archive is referred to in an external index of /// archives, such as you might create in Amazon DynamoDB. You can also get the vault inventory to obtain a list of archive IDs in a vault. For /// more information, see InitiateJob. </para> <para>You must provide a SHA256 tree hash of the data you are uploading. 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> . </para> <para>You can optionally specify an archive description of up to 1,024 printable ASCII characters. You can get the /// archive description when you either retrieve the archive or get the vault inventory. For more information, see InitiateJob. Amazon Glacier /// does not interpret the description in any way. An archive description does not need to be unique. You cannot use the description to retrieve /// or sort the archive list. </para> <para>Archives are immutable. After you upload an archive, you cannot edit the archive or its description. /// </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-an-archive.html">Uploading an Archive in Amazon Glacier</a> and <a href="http://docs.aws.amazon.com/amazonglacier/latest/dev/api-archive-post.html">Upload Archive</a> in the <i>Amazon Glacier Developer /// Guide</i> . /// </para> /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the UploadArchive service method on /// AmazonGlacier.</param> /// /// <returns>The response from the UploadArchive 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.RequestTimeoutException" /> /// <exception cref="T:Amazon.Glacier.Model.ServiceUnavailableException" /> /// <exception cref="T:Amazon.Glacier.Model.InvalidParameterValueException" /> public UploadArchiveResponse UploadArchive(UploadArchiveRequest request) { var task = UploadArchiveAsync(request); try { return task.Result; } catch(AggregateException e) { throw e.InnerException; } }
/// <summary> /// Initiates the asynchronous execution of the UploadArchive operation. /// <seealso cref="Amazon.Glacier.IAmazonGlacier.UploadArchive"/> /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the UploadArchive 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<UploadArchiveResponse> UploadArchiveAsync(UploadArchiveRequest request, CancellationToken cancellationToken = default(CancellationToken)) { var marshaller = new UploadArchiveRequestMarshaller(); var unmarshaller = UploadArchiveResponseUnmarshaller.GetInstance(); var response = await Invoke<IRequest, UploadArchiveRequest, UploadArchiveResponse>(request, marshaller, unmarshaller, signer, cancellationToken) .ConfigureAwait(continueOnCapturedContext: false); return response; }