/* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. * A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file is distributed * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either * express or implied. See the License for the specific language governing * permissions and limitations under the License. */ using System; using System.Collections.Generic; using System.IO; using System.Text; using System.Threading; using System.Threading.Tasks; using Amazon.Runtime.Internal.Util; using Amazon.S3.Model; using Amazon.S3.Transfer.Internal; using Amazon.Util; namespace Amazon.S3.Transfer { /// /// /// Provides a high level utility for managing transfers to and from Amazon S3. /// /// /// TransferUtility provides a simple API for /// uploading content to and downloading content /// from Amazon S3. It makes extensive use of Amazon S3 multipart uploads to /// achieve enhanced throughput, performance, and reliability. /// /// /// When uploading large files by specifying file paths instead of a stream, /// TransferUtility uses multiple threads to upload /// multiple parts of a single upload at once. When dealing with large content /// sizes and high bandwidth, this can increase throughput significantly. /// /// /// /// /// Transfers are stored in memory. If the application is restarted, /// previous transfers are no longer accessible. In this situation, if necessary, /// you should clean up any multipart uploads that are incomplete. /// /// public partial interface ITransferUtility { #region UploadDirectory /// /// Uploads files from a specified directory. /// The object key is derived from the file names /// inside the directory. /// 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. /// /// /// /// 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.AbortMultipartUploads() to abort the incomplete multipart uploads. /// /// /// /// The source directory, that is, the directory containing the files to upload. /// /// /// The target Amazon S3 bucket, that is, the name of the bucket to upload the files to. /// /// /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// /// The task object representing the asynchronous operation. Task UploadDirectoryAsync(string directory, string bucketName, CancellationToken cancellationToken = default(CancellationToken)); /// /// Uploads files from a specified directory. /// The object key is derived from the file names /// inside the directory. /// 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. /// /// /// /// 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.AbortMultipartUploads() to abort the incomplete multipart uploads. /// /// /// /// The source directory, that is, the directory containing the files to upload. /// /// /// The target Amazon S3 bucket, that is, the name of the bucket to upload the files to. /// /// /// A pattern used to identify the files from the source directory to upload. /// /// /// A search option that specifies whether to recursively search for files to upload /// in subdirectories. /// /// /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// /// The task object representing the asynchronous operation. Task UploadDirectoryAsync(string directory, string bucketName, string searchPattern, SearchOption searchOption, CancellationToken cancellationToken = default(CancellationToken)); /// /// Uploads files from a specified directory. /// The object key is derived from the file names /// inside the directory. /// 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. /// /// /// /// 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.AbortMultipartUploads() to abort the incomplete multipart uploads. /// /// /// /// The request that contains all the parameters required to upload a directory. /// /// /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// /// The task object representing the asynchronous operation. Task UploadDirectoryAsync(TransferUtilityUploadDirectoryRequest request, CancellationToken cancellationToken = default(CancellationToken)); #endregion #region DownloadDirectory /// /// Downloads the objects in Amazon S3 that have a key that starts with the value /// specified by s3Directory. /// /// /// The name of the bucket containing the Amazon S3 objects to download. /// /// /// The directory in Amazon S3 to download. /// /// /// The local directory to download the objects to. /// /// /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// /// The task object representing the asynchronous operation. Task DownloadDirectoryAsync(string bucketName, string s3Directory, string localDirectory, CancellationToken cancellationToken = default(CancellationToken)); /// /// Downloads the objects in Amazon S3 that have a key that starts with the value /// specified by the S3Directory /// property of the passed in TransferUtilityDownloadDirectoryRequest object. /// /// /// Contains all the parameters required to download objects from Amazon S3 /// into a local directory. /// /// /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// /// The task object representing the asynchronous operation. Task DownloadDirectoryAsync(TransferUtilityDownloadDirectoryRequest request, CancellationToken cancellationToken = default(CancellationToken)); #endregion #region Download /// /// Downloads the content from Amazon S3 and writes it to the specified file. /// /// /// The file path where the content from Amazon S3 will be written to. /// /// /// The name of the bucket containing the Amazon S3 object to download. /// /// /// The key under which the Amazon S3 object is stored. /// /// /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// /// The task object representing the asynchronous operation. Task DownloadAsync(string filePath, string bucketName, string key, CancellationToken cancellationToken = default(CancellationToken)); #endregion } }