Skip to content

Commit c0693f8

Browse files
Added UploadWithResponse and UploadWithResponseAsync methods to ITransferUtility interface (#4143)
1 parent 6e1ebab commit c0693f8

File tree

5 files changed

+243
-229
lines changed

5 files changed

+243
-229
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"services": [
3+
{
4+
"serviceName": "S3",
5+
"type": "patch",
6+
"changeLogMessages": [
7+
"Added UploadWithResponse and UploadWithResponseAsync methods to ITransferUtility interface"
8+
]
9+
}
10+
]
11+
}

sdk/src/Services/S3/Custom/Transfer/_async/ITransferUtility.async.cs

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,122 @@ public partial interface ITransferUtility : IDisposable
168168
/// </param>
169169
/// <returns>The task object representing the asynchronous operation.</returns>
170170
Task UploadAsync(TransferUtilityUploadRequest request, CancellationToken cancellationToken = default(CancellationToken));
171+
172+
/// <summary>
173+
/// Uploads the specified file and returns response metadata.
174+
/// The object key is derived from the file's name.
175+
/// Multiple threads are used to read the file and perform multiple uploads in parallel.
176+
/// For large uploads, the file will be divided and uploaded in parts using
177+
/// Amazon S3's multipart API. The parts will be reassembled as one object in
178+
/// Amazon S3.
179+
/// </summary>
180+
/// <remarks>
181+
/// <para>
182+
/// If you are uploading large files, TransferUtility will use multipart upload to fulfill the request.
183+
/// If a multipart upload is interrupted, TransferUtility will attempt to abort the multipart upload.
184+
/// Under certain circumstances (network outage, power failure, etc.), TransferUtility will not be able
185+
/// to abort the multipart upload. In this case, in order to stop getting charged for the storage of uploaded parts,
186+
/// you should manually invoke TransferUtility.AbortMultipartUploadsAsync() to abort the incomplete multipart uploads.
187+
/// </para>
188+
/// </remarks>
189+
/// <param name="filePath">
190+
/// The file path of the file to upload.
191+
/// </param>
192+
/// <param name="bucketName">
193+
/// The target Amazon S3 bucket, that is, the name of the bucket to upload the file to.
194+
/// </param>
195+
/// <param name="cancellationToken">
196+
/// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
197+
/// </param>
198+
/// <returns>The task object representing the asynchronous operation with upload response metadata.</returns>
199+
Task<TransferUtilityUploadResponse> UploadWithResponseAsync(string filePath, string bucketName, CancellationToken cancellationToken = default(CancellationToken));
200+
201+
/// <summary>
202+
/// Uploads the specified file and returns response metadata.
203+
/// Multiple threads are used to read the file and perform multiple uploads in parallel.
204+
/// For large uploads, the file will be divided and uploaded in parts using
205+
/// Amazon S3's multipart API. The parts will be reassembled as one object in
206+
/// Amazon S3.
207+
/// </summary>
208+
/// <remarks>
209+
/// <para>
210+
/// If you are uploading large files, TransferUtility will use multipart upload to fulfill the request.
211+
/// If a multipart upload is interrupted, TransferUtility will attempt to abort the multipart upload.
212+
/// Under certain circumstances (network outage, power failure, etc.), TransferUtility will not be able
213+
/// to abort the multipart upload. In this case, in order to stop getting charged for the storage of uploaded parts,
214+
/// you should manually invoke TransferUtility.AbortMultipartUploadsAsync() to abort the incomplete multipart uploads.
215+
/// </para>
216+
/// </remarks>
217+
/// <param name="filePath">
218+
/// The file path of the file to upload.
219+
/// </param>
220+
/// <param name="bucketName">
221+
/// The target Amazon S3 bucket, that is, the name of the bucket to upload the file to.
222+
/// </param>
223+
/// <param name="key">
224+
/// The key under which the Amazon S3 object is stored.
225+
/// </param>
226+
/// <param name="cancellationToken">
227+
/// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
228+
/// </param>
229+
/// <returns>The task object representing the asynchronous operation with upload response metadata.</returns>
230+
Task<TransferUtilityUploadResponse> UploadWithResponseAsync(string filePath, string bucketName, string key, CancellationToken cancellationToken = default(CancellationToken));
231+
232+
/// <summary>
233+
/// Uploads the contents of the specified stream and returns response metadata.
234+
/// For large uploads, the file will be divided and uploaded in parts using
235+
/// Amazon S3's multipart API. The parts will be reassembled as one object in
236+
/// Amazon S3.
237+
/// </summary>
238+
/// <remarks>
239+
/// <para>
240+
/// If you are uploading large files, TransferUtility will use multipart upload to fulfill the request.
241+
/// If a multipart upload is interrupted, TransferUtility will attempt to abort the multipart upload.
242+
/// Under certain circumstances (network outage, power failure, etc.), TransferUtility will not be able
243+
/// to abort the multipart upload. In this case, in order to stop getting charged for the storage of uploaded parts,
244+
/// you should manually invoke TransferUtility.AbortMultipartUploadsAsync() to abort the incomplete multipart uploads.
245+
/// </para>
246+
/// </remarks>
247+
/// <param name="stream">
248+
/// The stream to read to obtain the content to upload.
249+
/// </param>
250+
/// <param name="bucketName">
251+
/// The target Amazon S3 bucket, that is, the name of the bucket to upload the stream to.
252+
/// </param>
253+
/// <param name="key">
254+
/// The key under which the Amazon S3 object is stored.
255+
/// </param>
256+
/// <param name="cancellationToken">
257+
/// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
258+
/// </param>
259+
/// <returns>The task object representing the asynchronous operation with upload response metadata.</returns>
260+
Task<TransferUtilityUploadResponse> UploadWithResponseAsync(Stream stream, string bucketName, string key, CancellationToken cancellationToken = default(CancellationToken));
261+
262+
/// <summary>
263+
/// Uploads the file or stream specified by the request and returns response metadata.
264+
/// To track the progress of the upload,
265+
/// add an event listener to the request's <c>UploadProgressEvent</c>.
266+
/// For large uploads, the file will be divided and uploaded in parts using
267+
/// Amazon S3's multipart API. The parts will be reassembled as one object in
268+
/// Amazon S3.
269+
/// </summary>
270+
/// <remarks>
271+
/// <para>
272+
/// If you are uploading large files, TransferUtility will use multipart upload to fulfill the request.
273+
/// If a multipart upload is interrupted, TransferUtility will attempt to abort the multipart upload.
274+
/// Under certain circumstances (network outage, power failure, etc.), TransferUtility will not be able
275+
/// to abort the multipart upload. In this case, in order to stop getting charged for the storage of uploaded parts,
276+
/// you should manually invoke TransferUtility.AbortMultipartUploadsAsync() to abort the incomplete multipart uploads.
277+
/// </para>
278+
/// </remarks>
279+
/// <param name="request">
280+
/// Contains all the parameters required to upload to Amazon S3.
281+
/// </param>
282+
/// <param name="cancellationToken">
283+
/// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
284+
/// </param>
285+
/// <returns>The task object representing the asynchronous operation with upload response metadata.</returns>
286+
Task<TransferUtilityUploadResponse> UploadWithResponseAsync(TransferUtilityUploadRequest request, CancellationToken cancellationToken = default(CancellationToken));
171287
#endregion
172288

173289
#region AbortMultipartUploads

sdk/src/Services/S3/Custom/Transfer/_async/TransferUtility.async.cs

Lines changed: 4 additions & 133 deletions
Original file line numberDiff line numberDiff line change
@@ -218,157 +218,28 @@ public partial class TransferUtility : ITransferUtility
218218
}
219219
}
220220

221-
/// <summary>
222-
/// Uploads the specified file and returns response metadata.
223-
/// The object key is derived from the file's name.
224-
/// Multiple threads are used to read the file and perform multiple uploads in parallel.
225-
/// For large uploads, the file will be divided and uploaded in parts using
226-
/// Amazon S3's multipart API. The parts will be reassembled as one object in
227-
/// Amazon S3.
228-
/// </summary>
229-
/// <remarks>
230-
/// <para>
231-
/// If you are uploading large files, TransferUtility will use multipart upload to fulfill the request.
232-
/// If a multipart upload is interrupted, TransferUtility will attempt to abort the multipart upload.
233-
/// Under certain circumstances (network outage, power failure, etc.), TransferUtility will not be able
234-
/// to abort the multipart upload. In this case, in order to stop getting charged for the storage of uploaded parts,
235-
/// you should manually invoke TransferUtility.AbortMultipartUploadsAsync() to abort the incomplete multipart uploads.
236-
/// </para>
237-
/// <para>
238-
/// For nonseekable streams or streams with an unknown length, TransferUtility will use multipart upload and buffer up to a part size in memory
239-
/// until the final part is reached and complete the upload. The buffer for the multipart upload is controlled by S3Constants.MinPartSize
240-
/// 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)
241-
/// via the BufferSize property on the ClientConfig.The default value for this is 8192 bytes.
242-
/// </para>
243-
/// </remarks>
244-
/// <param name="filePath">
245-
/// The file path of the file to upload.
246-
/// </param>
247-
/// <param name="bucketName">
248-
/// The target Amazon S3 bucket, that is, the name of the bucket to upload the file to.
249-
/// </param>
250-
/// <param name="cancellationToken">
251-
/// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
252-
/// </param>
253-
/// <returns>The task object representing the asynchronous operation with upload response metadata.</returns>
221+
/// <inheritdoc/>
254222
public async Task<TransferUtilityUploadResponse> UploadWithResponseAsync(string filePath, string bucketName, CancellationToken cancellationToken = default(CancellationToken))
255223
{
256224
var request = ConstructUploadRequest(filePath, bucketName);
257225
return await UploadWithResponseAsync(request, cancellationToken).ConfigureAwait(false);
258226
}
259227

260-
/// <summary>
261-
/// Uploads the specified file and returns response metadata.
262-
/// Multiple threads are used to read the file and perform multiple uploads in parallel.
263-
/// For large uploads, the file will be divided and uploaded in parts using
264-
/// Amazon S3's multipart API. The parts will be reassembled as one object in
265-
/// Amazon S3.
266-
/// </summary>
267-
/// <remarks>
268-
/// <para>
269-
/// If you are uploading large files, TransferUtility will use multipart upload to fulfill the request.
270-
/// If a multipart upload is interrupted, TransferUtility will attempt to abort the multipart upload.
271-
/// Under certain circumstances (network outage, power failure, etc.), TransferUtility will not be able
272-
/// to abort the multipart upload. In this case, in order to stop getting charged for the storage of uploaded parts,
273-
/// you should manually invoke TransferUtility.AbortMultipartUploadsAsync() to abort the incomplete multipart uploads.
274-
/// </para>
275-
/// <para>
276-
/// For nonseekable streams or streams with an unknown length, TransferUtility will use multipart upload and buffer up to a part size in memory
277-
/// until the final part is reached and complete the upload. The buffer for the multipart upload is controlled by S3Constants.MinPartSize
278-
/// 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)
279-
/// via the BufferSize property on the ClientConfig.The default value for this is 8192 bytes.
280-
/// </para>
281-
/// </remarks>
282-
/// <param name="filePath">
283-
/// The file path of the file to upload.
284-
/// </param>
285-
/// <param name="bucketName">
286-
/// The target Amazon S3 bucket, that is, the name of the bucket to upload the file to.
287-
/// </param>
288-
/// <param name="key">
289-
/// The key under which the Amazon S3 object is stored.
290-
/// </param>
291-
/// <param name="cancellationToken">
292-
/// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
293-
/// </param>
294-
/// <returns>The task object representing the asynchronous operation with upload response metadata.</returns>
228+
/// <inheritdoc/>
295229
public async Task<TransferUtilityUploadResponse> UploadWithResponseAsync(string filePath, string bucketName, string key, CancellationToken cancellationToken = default(CancellationToken))
296230
{
297231
var request = ConstructUploadRequest(filePath, bucketName, key);
298232
return await UploadWithResponseAsync(request, cancellationToken).ConfigureAwait(false);
299233
}
300234

301-
/// <summary>
302-
/// Uploads the contents of the specified stream and returns response metadata.
303-
/// For large uploads, the file will be divided and uploaded in parts using
304-
/// Amazon S3's multipart API. The parts will be reassembled as one object in
305-
/// Amazon S3.
306-
/// </summary>
307-
/// <remarks>
308-
/// <para>
309-
/// If you are uploading large files, TransferUtility will use multipart upload to fulfill the request.
310-
/// If a multipart upload is interrupted, TransferUtility will attempt to abort the multipart upload.
311-
/// Under certain circumstances (network outage, power failure, etc.), TransferUtility will not be able
312-
/// to abort the multipart upload. In this case, in order to stop getting charged for the storage of uploaded parts,
313-
/// you should manually invoke TransferUtility.AbortMultipartUploadsAsync() to abort the incomplete multipart uploads.
314-
/// </para>
315-
/// <para>
316-
/// For nonseekable streams or streams with an unknown length, TransferUtility will use multipart upload and buffer up to a part size in memory
317-
/// until the final part is reached and complete the upload. The buffer for the multipart upload is controlled by S3Constants.MinPartSize
318-
/// 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)
319-
/// via the BufferSize property on the ClientConfig.The default value for this is 8192 bytes.
320-
/// </para>
321-
/// </remarks>
322-
/// <param name="stream">
323-
/// The stream to read to obtain the content to upload.
324-
/// </param>
325-
/// <param name="bucketName">
326-
/// The target Amazon S3 bucket, that is, the name of the bucket to upload the stream to.
327-
/// </param>
328-
/// <param name="key">
329-
/// The key under which the Amazon S3 object is stored.
330-
/// </param>
331-
/// <param name="cancellationToken">
332-
/// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
333-
/// </param>
334-
/// <returns>The task object representing the asynchronous operation with upload response metadata.</returns>
235+
/// <inheritdoc/>
335236
public async Task<TransferUtilityUploadResponse> UploadWithResponseAsync(Stream stream, string bucketName, string key, CancellationToken cancellationToken = default(CancellationToken))
336237
{
337238
var request = ConstructUploadRequest(stream, bucketName, key);
338239
return await UploadWithResponseAsync(request, cancellationToken).ConfigureAwait(false);
339240
}
340241

341-
/// <summary>
342-
/// Uploads the file or stream specified by the request and returns response metadata.
343-
/// To track the progress of the upload,
344-
/// add an event listener to the request's <c>UploadProgressEvent</c>.
345-
/// For large uploads, the file will be divided and uploaded in parts using
346-
/// Amazon S3's multipart API. The parts will be reassembled as one object in
347-
/// Amazon S3.
348-
/// </summary>
349-
/// <remarks>
350-
/// <para>
351-
/// If you are uploading large files, TransferUtility will use multipart upload to fulfill the request.
352-
/// If a multipart upload is interrupted, TransferUtility will attempt to abort the multipart upload.
353-
/// Under certain circumstances (network outage, power failure, etc.), TransferUtility will not be able
354-
/// to abort the multipart upload. In this case, in order to stop getting charged for the storage of uploaded parts,
355-
/// you should manually invoke TransferUtility.AbortMultipartUploadsAsync() to abort the incomplete multipart uploads.
356-
/// </para>
357-
/// <para>
358-
/// For nonseekable streams or streams with an unknown length, TransferUtility will use multipart upload and buffer up to a part size in memory
359-
/// until the final part is reached and complete the upload. The part size buffer for the multipart upload is controlled by the partSize
360-
/// specified on the TransferUtilityUploadRequest, and if none is specified it defaults to S3Constants.MinPartSize (5 megabytes).
361-
/// You can also adjust the read buffer size (i.e. how many bytes to read before adding it to the
362-
/// part buffer) via the BufferSize property on the ClientConfig. The default value for this is 8192 bytes.
363-
/// </para>
364-
/// </remarks>
365-
/// <param name="request">
366-
/// Contains all the parameters required to upload to Amazon S3.
367-
/// </param>
368-
/// <param name="cancellationToken">
369-
/// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
370-
/// </param>
371-
/// <returns>The task object representing the asynchronous operation with upload response metadata.</returns>
242+
/// <inheritdoc/>
372243
public async Task<TransferUtilityUploadResponse> UploadWithResponseAsync(TransferUtilityUploadRequest request, CancellationToken cancellationToken = default(CancellationToken))
373244
{
374245
using(CreateSpan(nameof(UploadWithResponseAsync), null, Amazon.Runtime.Telemetry.Tracing.SpanKind.CLIENT))

0 commit comments

Comments
 (0)