internal BaseCommand GetUploadCommand(TransferUtilityUploadRequest request, SemaphoreSlim asyncThrottler) { validate(request); if (IsMultipartUpload(request)) { var command = new MultipartUploadCommand(this._s3Client, this._config, request); command.AsyncThrottler = asyncThrottler; return(command); } else { var command = new SimpleUploadCommand(this._s3Client, this._config, request); command.AsyncThrottler = asyncThrottler; return(command); } }
/// <summary> /// Uploads the file or stream specified by the request. /// To track the progress of the upload, /// add an event listener to the request's <c>UploadProgressEvent</c>. /// For large uploads, the file will be divided and uploaded in parts using /// Amazon S3's multipart API. The parts will be reassembled as one object in /// Amazon S3. /// </summary> /// <param name="request"> /// Contains all the parameters required to upload to Amazon S3. /// </param> public void Upload(TransferUtilityUploadRequest request) { validate(request); BaseCommand command; if (request.ContentLength < this._config.MinSizeBeforePartUpload) { command = new SimpleUploadCommand(this._s3Client, this._config, request); } else { command = new MultipartUploadCommand(this._s3Client, this._config, request); } command.Execute(); }
/// <summary> /// <para> /// Uploads the specified file to Amazon Glacier for archival storage in the /// specified vault in the specified user's account. For small archives, this /// method uploads the archive directly to Glacier. For larger archives, /// this method uses Glacier's multipart upload API to split the upload /// into multiple parts for better error recovery if any errors are /// encountered while streaming the data to Amazon Glacier. /// </para> /// </summary> /// <param name="vaultName">The name of the vault to download the archive from.</param> /// <param name="archiveDescription">A description for the archive.</param> /// <param name="filepath">The file path to the file to upload.</param> /// <param name="options">Additional options that can be used for the upload.</param> /// <returns>The results of the upload including the archive ID.</returns> public UploadResult Upload(string vaultName, string archiveDescription, string filepath, UploadOptions options) { FileInfo fi = new FileInfo(filepath); BaseUploadCommand command; if (fi.Length > MULTIPART_UPLOAD_SIZE_THRESHOLD) { command = new MultipartUploadCommand(this, vaultName, archiveDescription, filepath, options); } else { command = new SinglepartUploadCommand(this, vaultName, archiveDescription, filepath, options); } command.Execute(); return(command.UploadResult); }
/// <summary> /// Initiates the asynchronous execution of the Upload operation. /// <seealso cref="M:Amazon.S3.Transfer.TransferUtility.Upload"/> /// </summary> /// <param name="request"> /// Contains all the parameters required to upload to Amazon S3. /// </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> /// <exception cref="T:System.ArgumentNullException"></exception> /// <exception cref="T:System.Net.WebException"></exception> /// <exception cref="T:Amazon.S3.AmazonS3Exception"></exception> /// <returns>An IAsyncResult that can be used to poll, or wait for results, or both. /// This values is also needed when invoking EndUpload.</returns> public IAsyncResult BeginUpload(TransferUtilityUploadRequest request, AsyncCallback callback, object state) { validate(request); BaseCommand command; if (request.ContentLength < this._config.MinSizeBeforePartUpload) { command = new SimpleUploadCommand(this._s3Client, this._config, request); } else { command = new MultipartUploadCommand(this._s3Client, this._config, request); } return(beginOperation(command, callback, state)); }
/// <summary> /// <para> /// Uploads the specified file to Amazon Glacier for archival storage in the /// specified vault in the specified user's account. For small archives, this /// method uploads the archive directly to Glacier. For larger archives, /// this method uses Glacier's multipart upload API to split the upload /// into multiple parts for better error recovery if any errors are /// encountered while streaming the data to Amazon Glacier. /// </para> /// </summary> /// <param name="vaultName">The name of the vault to download the archive from.</param> /// <param name="archiveDescription">A description for the archive.</param> /// <param name="filepath">The file path to the file to upload.</param> /// <param name="options">Additional options that can be used for the upload.</param> /// <returns>The results of the upload including the archive ID.</returns> public async Task <UploadResult> UploadAsync(string vaultName, string archiveDescription, string filepath, UploadOptions options) { FileInfo fi = new FileInfo(filepath); BaseUploadCommand command; if (fi.Length > MULTIPART_UPLOAD_SIZE_THRESHOLD) { command = new MultipartUploadCommand(this, vaultName, archiveDescription, filepath, options); } else { command = new SinglepartUploadCommand(this, vaultName, archiveDescription, filepath, options); } await command.ExecuteAsync().ConfigureAwait(false); return(command.UploadResult); }