Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions generator/.DevConfigs/f8a7b6c5-d4e3-2f1a-0b9c-8d7e6f5a4b3c.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"services": [
{
"serviceName": "S3",
"type": "patch",
"changeLogMessages": [
"Added UploadWithResponse and UploadWithResponseAsync methods to ITransferUtility interface"
]
}
]
}
116 changes: 116 additions & 0 deletions sdk/src/Services/S3/Custom/Transfer/_async/ITransferUtility.async.cs
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,122 @@ public partial interface ITransferUtility : IDisposable
/// </param>
/// <returns>The task object representing the asynchronous operation.</returns>
Task UploadAsync(TransferUtilityUploadRequest request, CancellationToken cancellationToken = default(CancellationToken));

/// <summary>
/// Uploads the specified file and returns response metadata.
/// The object key is derived from the file's name.
/// Multiple threads are used to read the file and perform multiple uploads in parallel.
/// 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>
/// <remarks>
/// <para>
/// If you are uploading large files, TransferUtility will use multipart upload to fulfill the request.
/// If a multipart upload is interrupted, TransferUtility will attempt to abort the multipart upload.
/// Under certain circumstances (network outage, power failure, etc.), TransferUtility will not be able
/// to abort the multipart upload. In this case, in order to stop getting charged for the storage of uploaded parts,
/// you should manually invoke TransferUtility.AbortMultipartUploadsAsync() to abort the incomplete multipart uploads.
/// </para>
/// </remarks>
/// <param name="filePath">
/// The file path of the file to upload.
/// </param>
/// <param name="bucketName">
/// The target Amazon S3 bucket, that is, the name of the bucket to upload the file to.
/// </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 with upload response metadata.</returns>
Task<TransferUtilityUploadResponse> UploadWithResponseAsync(string filePath, string bucketName, CancellationToken cancellationToken = default(CancellationToken));

/// <summary>
/// Uploads the specified file and returns response metadata.
/// Multiple threads are used to read the file and perform multiple uploads in parallel.
/// 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>
/// <remarks>
/// <para>
/// If you are uploading large files, TransferUtility will use multipart upload to fulfill the request.
/// If a multipart upload is interrupted, TransferUtility will attempt to abort the multipart upload.
/// Under certain circumstances (network outage, power failure, etc.), TransferUtility will not be able
/// to abort the multipart upload. In this case, in order to stop getting charged for the storage of uploaded parts,
/// you should manually invoke TransferUtility.AbortMultipartUploadsAsync() to abort the incomplete multipart uploads.
/// </para>
/// </remarks>
/// <param name="filePath">
/// The file path of the file to upload.
/// </param>
/// <param name="bucketName">
/// The target Amazon S3 bucket, that is, the name of the bucket to upload the file to.
/// </param>
/// <param name="key">
/// The key under which the Amazon S3 object is stored.
/// </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 with upload response metadata.</returns>
Task<TransferUtilityUploadResponse> UploadWithResponseAsync(string filePath, string bucketName, string key, CancellationToken cancellationToken = default(CancellationToken));

/// <summary>
/// Uploads the contents of the specified stream and returns response metadata.
/// 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>
/// <remarks>
/// <para>
/// If you are uploading large files, TransferUtility will use multipart upload to fulfill the request.
/// If a multipart upload is interrupted, TransferUtility will attempt to abort the multipart upload.
/// Under certain circumstances (network outage, power failure, etc.), TransferUtility will not be able
/// to abort the multipart upload. In this case, in order to stop getting charged for the storage of uploaded parts,
/// you should manually invoke TransferUtility.AbortMultipartUploadsAsync() to abort the incomplete multipart uploads.
/// </para>
/// </remarks>
/// <param name="stream">
/// The stream to read to obtain the content to upload.
/// </param>
/// <param name="bucketName">
/// The target Amazon S3 bucket, that is, the name of the bucket to upload the stream to.
/// </param>
/// <param name="key">
/// The key under which the Amazon S3 object is stored.
/// </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 with upload response metadata.</returns>
Task<TransferUtilityUploadResponse> UploadWithResponseAsync(Stream stream, string bucketName, string key, CancellationToken cancellationToken = default(CancellationToken));

/// <summary>
/// Uploads the file or stream specified by the request and returns response metadata.
/// 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>
/// <remarks>
/// <para>
/// If you are uploading large files, TransferUtility will use multipart upload to fulfill the request.
/// If a multipart upload is interrupted, TransferUtility will attempt to abort the multipart upload.
/// Under certain circumstances (network outage, power failure, etc.), TransferUtility will not be able
/// to abort the multipart upload. In this case, in order to stop getting charged for the storage of uploaded parts,
/// you should manually invoke TransferUtility.AbortMultipartUploadsAsync() to abort the incomplete multipart uploads.
/// </para>
/// </remarks>
/// <param name="request">
/// Contains all the parameters required to upload to Amazon S3.
/// </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 with upload response metadata.</returns>
Task<TransferUtilityUploadResponse> UploadWithResponseAsync(TransferUtilityUploadRequest request, CancellationToken cancellationToken = default(CancellationToken));
#endregion

#region AbortMultipartUploads
Expand Down
137 changes: 4 additions & 133 deletions sdk/src/Services/S3/Custom/Transfer/_async/TransferUtility.async.cs
Original file line number Diff line number Diff line change
Expand Up @@ -218,157 +218,28 @@ public partial class TransferUtility : ITransferUtility
}
}

/// <summary>
/// Uploads the specified file and returns response metadata.
/// The object key is derived from the file's name.
/// Multiple threads are used to read the file and perform multiple uploads in parallel.
/// 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>
/// <remarks>
/// <para>
/// If you are uploading large files, TransferUtility will use multipart upload to fulfill the request.
/// If a multipart upload is interrupted, TransferUtility will attempt to abort the multipart upload.
/// Under certain circumstances (network outage, power failure, etc.), TransferUtility will not be able
/// to abort the multipart upload. In this case, in order to stop getting charged for the storage of uploaded parts,
/// you should manually invoke TransferUtility.AbortMultipartUploadsAsync() to abort the incomplete multipart uploads.
/// </para>
/// <para>
/// For nonseekable streams or streams with an unknown length, TransferUtility will use multipart upload and buffer up to a part size in memory
/// until the final part is reached and complete the upload. The buffer for the multipart upload is controlled by S3Constants.MinPartSize
/// and the default value is 5 megabytes. You can also adjust the read buffer size(i.e.how many bytes to read before writing to the part buffer)
/// via the BufferSize property on the ClientConfig.The default value for this is 8192 bytes.
/// </para>
/// </remarks>
/// <param name="filePath">
/// The file path of the file to upload.
/// </param>
/// <param name="bucketName">
/// The target Amazon S3 bucket, that is, the name of the bucket to upload the file to.
/// </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 with upload response metadata.</returns>
/// <inheritdoc/>
public async Task<TransferUtilityUploadResponse> UploadWithResponseAsync(string filePath, string bucketName, CancellationToken cancellationToken = default(CancellationToken))
{
var request = ConstructUploadRequest(filePath, bucketName);
return await UploadWithResponseAsync(request, cancellationToken).ConfigureAwait(false);
}

/// <summary>
/// Uploads the specified file and returns response metadata.
/// Multiple threads are used to read the file and perform multiple uploads in parallel.
/// 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>
/// <remarks>
/// <para>
/// If you are uploading large files, TransferUtility will use multipart upload to fulfill the request.
/// If a multipart upload is interrupted, TransferUtility will attempt to abort the multipart upload.
/// Under certain circumstances (network outage, power failure, etc.), TransferUtility will not be able
/// to abort the multipart upload. In this case, in order to stop getting charged for the storage of uploaded parts,
/// you should manually invoke TransferUtility.AbortMultipartUploadsAsync() to abort the incomplete multipart uploads.
/// </para>
/// <para>
/// For nonseekable streams or streams with an unknown length, TransferUtility will use multipart upload and buffer up to a part size in memory
/// until the final part is reached and complete the upload. The buffer for the multipart upload is controlled by S3Constants.MinPartSize
/// and the default value is 5 megabytes. You can also adjust the read buffer size(i.e.how many bytes to read before writing to the part buffer)
/// via the BufferSize property on the ClientConfig.The default value for this is 8192 bytes.
/// </para>
/// </remarks>
/// <param name="filePath">
/// The file path of the file to upload.
/// </param>
/// <param name="bucketName">
/// The target Amazon S3 bucket, that is, the name of the bucket to upload the file to.
/// </param>
/// <param name="key">
/// The key under which the Amazon S3 object is stored.
/// </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 with upload response metadata.</returns>
/// <inheritdoc/>
public async Task<TransferUtilityUploadResponse> UploadWithResponseAsync(string filePath, string bucketName, string key, CancellationToken cancellationToken = default(CancellationToken))
{
var request = ConstructUploadRequest(filePath, bucketName, key);
return await UploadWithResponseAsync(request, cancellationToken).ConfigureAwait(false);
}

/// <summary>
/// Uploads the contents of the specified stream and returns response metadata.
/// 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>
/// <remarks>
/// <para>
/// If you are uploading large files, TransferUtility will use multipart upload to fulfill the request.
/// If a multipart upload is interrupted, TransferUtility will attempt to abort the multipart upload.
/// Under certain circumstances (network outage, power failure, etc.), TransferUtility will not be able
/// to abort the multipart upload. In this case, in order to stop getting charged for the storage of uploaded parts,
/// you should manually invoke TransferUtility.AbortMultipartUploadsAsync() to abort the incomplete multipart uploads.
/// </para>
/// <para>
/// For nonseekable streams or streams with an unknown length, TransferUtility will use multipart upload and buffer up to a part size in memory
/// until the final part is reached and complete the upload. The buffer for the multipart upload is controlled by S3Constants.MinPartSize
/// and the default value is 5 megabytes. You can also adjust the read buffer size(i.e.how many bytes to read before writing to the part buffer)
/// via the BufferSize property on the ClientConfig.The default value for this is 8192 bytes.
/// </para>
/// </remarks>
/// <param name="stream">
/// The stream to read to obtain the content to upload.
/// </param>
/// <param name="bucketName">
/// The target Amazon S3 bucket, that is, the name of the bucket to upload the stream to.
/// </param>
/// <param name="key">
/// The key under which the Amazon S3 object is stored.
/// </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 with upload response metadata.</returns>
/// <inheritdoc/>
public async Task<TransferUtilityUploadResponse> UploadWithResponseAsync(Stream stream, string bucketName, string key, CancellationToken cancellationToken = default(CancellationToken))
{
var request = ConstructUploadRequest(stream, bucketName, key);
return await UploadWithResponseAsync(request, cancellationToken).ConfigureAwait(false);
}

/// <summary>
/// Uploads the file or stream specified by the request and returns response metadata.
/// 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>
/// <remarks>
/// <para>
/// If you are uploading large files, TransferUtility will use multipart upload to fulfill the request.
/// If a multipart upload is interrupted, TransferUtility will attempt to abort the multipart upload.
/// Under certain circumstances (network outage, power failure, etc.), TransferUtility will not be able
/// to abort the multipart upload. In this case, in order to stop getting charged for the storage of uploaded parts,
/// you should manually invoke TransferUtility.AbortMultipartUploadsAsync() to abort the incomplete multipart uploads.
/// </para>
/// <para>
/// For nonseekable streams or streams with an unknown length, TransferUtility will use multipart upload and buffer up to a part size in memory
/// until the final part is reached and complete the upload. The part size buffer for the multipart upload is controlled by the partSize
/// specified on the TransferUtilityUploadRequest, and if none is specified it defaults to S3Constants.MinPartSize (5 megabytes).
/// You can also adjust the read buffer size (i.e. how many bytes to read before adding it to the
/// part buffer) via the BufferSize property on the ClientConfig. The default value for this is 8192 bytes.
/// </para>
/// </remarks>
/// <param name="request">
/// Contains all the parameters required to upload to Amazon S3.
/// </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 with upload response metadata.</returns>
/// <inheritdoc/>
public async Task<TransferUtilityUploadResponse> UploadWithResponseAsync(TransferUtilityUploadRequest request, CancellationToken cancellationToken = default(CancellationToken))
{
using(CreateSpan(nameof(UploadWithResponseAsync), null, Amazon.Runtime.Telemetry.Tracing.SpanKind.CLIENT))
Expand Down
Loading