Contains all the parameters that can be set when making a this request with the TransferUtility method.
        public void SendDirectory(string directory, string bucket, string destinationPath)
        {
            try
            {
                var transferUtility = new TransferUtility(amazonS3Client);
                if (!transferUtility.S3Client.DoesS3BucketExist(bucket))
                    transferUtility.S3Client.PutBucket(new PutBucketRequest { BucketName = bucket });

                var request = new TransferUtilityUploadDirectoryRequest()
                {
                    BucketName = bucket,
                    Directory = directory,
                    KeyPrefix = destinationPath
                };
                request.UploadDirectoryProgressEvent += uploadDirectoryProgressCallback;

                transferUtility.UploadDirectory(request);
                transferUtility.Dispose();
            }
            catch (Exception ex)
            {
                throw new Exception("Error send directory to S3. " + ex.Message);
            }
        }
        /// <summary>
        /// Initiates the asynchronous execution of the UploadDirectory operation. 
        /// <seealso cref="M:Amazon.S3.Transfer.TransferUtility.UploadDirectory"/>
        /// </summary>
        /// <param name="directory">
        /// 	The source directory, that is, the directory containing the files to upload.
        /// </param>
        /// <param name="bucketName">
        /// 	The target Amazon S3 bucket, that is, the name of the bucket to upload the files to.
        /// </param>
        /// <param name="searchPattern">
        /// 	A pattern used to identify the files from the source directory to upload.
        /// </param>
        /// <param name="searchOption">
        /// 	A search option that specifies whether to recursively search for files to upload
        /// 	in subdirectories.
        /// </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 value is also needed when invoking EndUploadDirectory.</returns>
        public IAsyncResult BeginUploadDirectory(string directory, string bucketName, string searchPattern, SearchOption searchOption, AsyncCallback callback, object state)
        {
            TransferUtilityUploadDirectoryRequest request = new TransferUtilityUploadDirectoryRequest()
            {
                BucketName = bucketName,
                Directory = directory,
                SearchPattern = searchPattern,
                SearchOption = searchOption
            };

            return BeginUploadDirectory(request, callback, state);
        }
 /// <summary>
 /// 	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.
 /// </summary>
 /// <param name="directory">
 /// 	The source directory, that is, the directory containing the files to upload.
 /// </param>
 /// <param name="bucketName">
 /// 	The target Amazon S3 bucket, that is, the name of the bucket to upload the files to.
 /// </param>
 public void UploadDirectory(string directory, string bucketName)
 {
     TransferUtilityUploadDirectoryRequest request = new TransferUtilityUploadDirectoryRequest
     {
         BucketName = bucketName,
         Directory = directory
     };
     UploadDirectory(request);
 }
        /// <summary>
        /// This method is called in background thread so as not to block the UI as the upload is 
        /// going.
        /// </summary>
        /// <param name="state">unused</param>
        private void threadedUploadDirectory(object state)
        {
            try
            {
                // Make sure the bucket exists
                this._transferUtility.S3Client.PutBucket(new PutBucketRequest() { BucketName = this.Bucket });

                TransferUtilityUploadDirectoryRequest request = new TransferUtilityUploadDirectoryRequest()
                {
                    BucketName = this.Bucket,
                    Directory = this.UploadDirectory,
                    SearchOption = SearchOption.AllDirectories
                };
                request.UploadDirectoryProgressEvent += this.uploadDirectoryProgressCallback;
                this._transferUtility.UploadDirectory(request);

                displayMessageBox("Completed directory upload!", "Success", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            finally
            {
                updateIsEnabled(this._ctlUploadDirectory, true);
            }
        }
        /// <summary>
        /// This method is called in background thread so as not to block the UI as the upload is 
        /// going.
        /// </summary>
        /// <param name="state">unused</param>
        private void threadedUploadDirectory(object state)
        {
            try
            {
                // Make sure the bucket exists
                this._transferUtility.S3Client.PutBucket(new PutBucketRequest().WithBucketName(this.Bucket));

                TransferUtilityUploadDirectoryRequest request = new TransferUtilityUploadDirectoryRequest()
                    .WithBucketName(this.Bucket)
                    .WithDirectory(this.UploadDirectory)
                    .WithSearchOption(SearchOption.AllDirectories)
                    .WithTimeout(FIVE_MINUTES)
                    .WithSubscriber(this.uploadDirectoryProgressCallback); // Pass in a callback so upload progress can be tracked.
                this._transferUtility.UploadDirectory(request);

                displayMessageBox("Completed directory upload!", "Success", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            finally
            {
                updateIsEnabled(this._ctlUploadDirectory, true);
            }
        }
 /// <summary>
 /// 	Uploads the files in directory.  The object key is obtained 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.
 /// </summary>
 /// <param name="request">
 /// 	The request that contains all the parameters to upload a directory.
 /// </param>
 public void UploadDirectory(TransferUtilityUploadDirectoryRequest request)
 {
     validate(request);
     UploadDirectoryCommand command = new UploadDirectoryCommand(this, request);
     command.Execute();
 }
 /// <summary>
 /// 	Uploads the files in directory.  The object key is obtained 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.
 /// </summary>
 /// <param name="directory">
 /// 	The directory containing files to upload.
 /// </param>
 /// <param name="bucketName">
 /// 	The name of the bucket to upload files to.
 /// </param>
 public void UploadDirectory(string directory, string bucketName)
 {
     TransferUtilityUploadDirectoryRequest request = new TransferUtilityUploadDirectoryRequest()
         .WithBucketName(bucketName)
         .WithDirectory(directory);
     UploadDirectory(request);
 }
        /// <summary>
        /// Initiates the asynchronous execution of the UploadDirectory operation. 
        /// <seealso cref="M:Amazon.S3.Transfer.TransferUtility.UploadDirectory"/>
        /// </summary>
        /// <param name="directory">
        /// 	The directory containing files to upload.
        /// </param>
        /// <param name="bucketName">
        /// 	The name of the bucket to upload files to.
        /// </param>
        /// <param name="searchPattern">
        /// 	The pattern used to find files to upload in the directory.
        /// </param>
        /// <param name="searchOption">
        /// 	The search option specifying whether or not to recursively search for files to upload
        /// 	in subdirectories or not.
        /// </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 value is also needed when invoking EndUploadDirectory.</returns>
        public IAsyncResult BeginUploadDirectory(string directory, string bucketName, string searchPattern, SearchOption searchOption, AsyncCallback callback, object state)
        {
            TransferUtilityUploadDirectoryRequest request = new TransferUtilityUploadDirectoryRequest()
                .WithBucketName(bucketName)
                .WithDirectory(directory)
                .WithSearchPattern(searchPattern)
                .WithSearchOption(searchOption);

            return BeginUploadDirectory(request, callback, state);
        }
Beispiel #9
0
 private void UploadDirectoryHelper(TransferUtilityUploadDirectoryRequest request)
 {
     validate(request);
     UploadDirectoryCommand command = new UploadDirectoryCommand(this, this._config, request);
     command.Execute();
 }
Beispiel #10
0
 private void UploadDirectoryHelper(string directory, string bucketName, string searchPattern, SearchOption searchOption)
 {
     TransferUtilityUploadDirectoryRequest request = new TransferUtilityUploadDirectoryRequest()
     {
         BucketName = bucketName,
         Directory = directory,
         SearchPattern = searchPattern,
         SearchOption = searchOption
     };
     UploadDirectoryHelper(request);
 }
Beispiel #11
0
 private void UploadDirectoryHelper(string directory, string bucketName)
 {
     TransferUtilityUploadDirectoryRequest request = new TransferUtilityUploadDirectoryRequest()
     {
         BucketName = bucketName,
         Directory = directory
     };
     UploadDirectoryHelper(request);
 }
 /// <summary>
 /// Initiates the asynchronous execution of the UploadDirectory operation.
 /// <seealso cref="Amazon.S3.IAmazonS3.AbortMultipartUpload"/>
 /// </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.AbortMultipartUploads() to abort the incomplete multipart uploads.
 /// </para>
 /// </remarks>
 /// <param name="request">
 ///     The request that contains all the parameters required to upload a directory.
 /// </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 UploadDirectoryAsync(TransferUtilityUploadDirectoryRequest request, CancellationToken cancellationToken = default(CancellationToken))
 {
     return(ExecuteAsync(() => UploadDirectoryHelper(request), cancellationToken));
 }
Beispiel #13
0
        /// <summary>
        /// ディレクトリ丸ごとコピー
        /// </summary>
        /// <param name="directory"></param>
        private void CopyDirectory( string directory )
        {
            var request = new TransferUtilityUploadDirectoryRequest
            {
                BucketName = this.Bucket,
                Directory = directory,
                KeyPrefix = procDirectoryName(directory)

            };
            if ( !OnlyCount ) transferUtility.UploadDirectory(request);
            Console.WriteLine("[{0}]", directory);
        }
 /// <summary>
 /// 	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.
 /// </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.AbortMultipartUploads() to abort the incomplete multipart uploads.
 /// </para>
 /// </remarks>
 /// <param name="request">
 /// 	The request that contains all the parameters required to upload a directory.
 /// </param>
 public void UploadDirectory(TransferUtilityUploadDirectoryRequest request)
 {
     try
     {
         UploadDirectoryAsync(request).Wait();
     }
     catch (AggregateException e)
     {
         ExceptionDispatchInfo.Capture(e.InnerException).Throw();
     }
 }
 /// <summary>
 /// 	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.
 /// </summary>
 /// <param name="request">
 /// 	The request that contains all the parameters required to upload a directory.
 /// </param>
 public void UploadDirectory(TransferUtilityUploadDirectoryRequest request)
 {
     UploadDirectoryHelper(request);
 }
 /// <summary>
 /// Initiates the asynchronous execution of the UploadDirectory operation. 
 /// <seealso cref="M:Amazon.S3.Transfer.TransferUtility.UploadDirectory"/>
 /// </summary>
 /// <param name="directory">
 /// 	The directory containing files to upload.
 /// </param>
 /// <param name="bucketName">
 /// 	The name of the bucket to upload files to.
 /// </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 value is also needed when invoking EndUploadDirectory.</returns>
 public IAsyncResult BeginUploadDirectory(string directory, string bucketName, AsyncCallback callback, object state)
 {
     TransferUtilityUploadDirectoryRequest request = new TransferUtilityUploadDirectoryRequest()
         .WithBucketName(bucketName)
         .WithDirectory(directory);
     return BeginUploadDirectory(request, callback, state);
 }
Beispiel #17
0
 public void UploadFolder(String folderPath)
 {
     MessageToUser m = new MessageToUser();
     Thread startingThread = new Thread(m.UploadToS3);
     startingThread.Start();
     TransferUtilityUploadDirectoryRequest request = new TransferUtilityUploadDirectoryRequest()
     {
         BucketName = _bucket,
         Directory = folderPath,
         SearchOption = SearchOption.AllDirectories,
         SearchPattern = "*.zip",
         KeyPrefix = "mods"
     };
     TransferUtility directorytTransferUtility = new TransferUtility(_client);
     directorytTransferUtility.UploadDirectory(request);
     MessageBox.Show("Done uploading files to s3");
 }
 /// <summary>
 /// Initiates the asynchronous execution of the UploadDirectory operation. 
 /// <seealso cref="M:Amazon.S3.Transfer.TransferUtility.UploadDirectory"/>
 /// </summary>
 /// <param name="request">
 /// 	The request that contains all the parameters to upload a directory.
 /// </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 value is also needed when invoking EndUploadDirectory.</returns>
 public IAsyncResult BeginUploadDirectory(TransferUtilityUploadDirectoryRequest request, AsyncCallback callback, object state)
 {
     validate(request);
     UploadDirectoryCommand command = new UploadDirectoryCommand(this, request);
     return beginOperation(command, callback, state);
 }
 /// <summary>
 /// 	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.
 /// </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.AbortMultipartUploads() to abort the incomplete multipart uploads.
 /// </para>
 /// </remarks>
 /// <param name="request">
 /// 	The request that contains all the parameters required to upload a directory.
 /// </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 UploadDirectoryAsync(TransferUtilityUploadDirectoryRequest request, CancellationToken cancellationToken = default(CancellationToken))
 {
     validate(request);
     UploadDirectoryCommand command = new UploadDirectoryCommand(this, this._config, request);
     command.UploadFilesConcurrently = request.UploadFilesConcurrently;
     return command.ExecuteAsync(cancellationToken);
 }
 /// <summary>
 /// 	Uploads the files in directory.  The object key is obtained 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.
 /// </summary>
 /// <param name="directory">
 /// 	The directory containing files to upload.
 /// </param>
 /// <param name="bucketName">
 /// 	The name of the bucket to upload files to.
 /// </param>
 /// <param name="searchPattern">
 /// 	The pattern used to find files to upload in the directory.
 /// </param>
 /// <param name="searchOption">
 /// 	The search option specifying whether or not to recursively search for files to upload
 /// 	in subdirectories or not.
 /// </param>
 public void UploadDirectory(string directory, string bucketName, string searchPattern, SearchOption searchOption)
 {
     TransferUtilityUploadDirectoryRequest request = new TransferUtilityUploadDirectoryRequest()
         .WithBucketName(bucketName)
         .WithDirectory(directory)
         .WithSearchPattern(searchPattern)
         .WithSearchOption(searchOption);
     UploadDirectory(request);
 }
Beispiel #21
0
        /// <summary>
        /// 	Uploads the files in directory.  The object key is obtained 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.
        /// </summary>
        /// <param name="request">
        /// 	The request that contains all the parameters to upload a directory.
        /// </param>
        public void UploadDirectory(TransferUtilityUploadDirectoryRequest request)
        {
            if (!request.IsSetDirectory())
            {
                throw new ArgumentNullException("directory");
            }
            if (!request.IsSetBucketName())
            {
                throw new ArgumentNullException("bucketName");
            }
            if (!Directory.Exists(request.Directory))
            {
                throw new ArgumentException(string.Format("The directory {0} does not exists!", request.Directory), "directory");
            }

            UploadDirectoryCommand command = new UploadDirectoryCommand(this, request);
            command.Execute();
        }
 void validate(TransferUtilityUploadDirectoryRequest request)
 {
     if (!request.IsSetDirectory())
     {
         throw new ArgumentNullException("directory");
     }
     if (!request.IsSetBucketName())
     {
         throw new ArgumentNullException("bucketName");
     }
     if (!Directory.Exists(request.Directory))
     {
         throw new ArgumentException(string.Format("The directory {0} does not exists!", request.Directory), "directory");
     }
 }
 /// <summary>
 /// 	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.
 /// </summary>
 /// <param name="directory">
 /// 	The source directory, that is, the directory containing the files to upload.
 /// </param>
 /// <param name="bucketName">
 /// 	The target Amazon S3 bucket, that is, the name of the bucket to upload the files to.
 /// </param>
 /// <param name="searchPattern">
 /// 	A pattern used to identify the files from the source directory to upload.
 /// </param>                                                                 
 /// <param name="searchOption">
 /// 	A search option that specifies whether to recursively search for files to upload
 /// 	in subdirectories.
 /// </param>
 public void UploadDirectory(string directory, string bucketName, string searchPattern, SearchOption searchOption)
 {
     TransferUtilityUploadDirectoryRequest request = new TransferUtilityUploadDirectoryRequest
     {
         BucketName = bucketName,
         Directory = directory,
         SearchPattern = searchPattern,
         SearchOption = searchOption
     };
     UploadDirectory(request);
 }
 static void validate(TransferUtilityUploadDirectoryRequest request)
 {
     if (!request.IsSetDirectory())
     {
         throw new InvalidOperationException("Directory not specified");
     }
     if (!request.IsSetBucketName())
     {
         throw new InvalidOperationException("BucketName not specified");
     }
     if (!Directory.Exists(request.Directory))
     {
         throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "The directory {0} does not exists!",
             request.Directory));
     }
 }
 /// <summary>
 /// Initiates the asynchronous execution of the UploadDirectory operation. 
 /// <seealso cref="M:Amazon.S3.Transfer.TransferUtility.UploadDirectory"/>
 /// </summary>
 /// <param name="directory">
 /// 	The source directory, that is, the directory containing the files to upload.
 /// </param>
 /// <param name="bucketName">
 /// 	The target Amazon S3 bucket, that is, the name of the bucket to upload the files to.
 /// </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 value is also needed when invoking EndUploadDirectory.</returns>
 public IAsyncResult BeginUploadDirectory(string directory, string bucketName, AsyncCallback callback, object state)
 {
     TransferUtilityUploadDirectoryRequest request = new TransferUtilityUploadDirectoryRequest
     {
         BucketName = bucketName,
         Directory = directory
     };
     return BeginUploadDirectory(request, callback, state);
 }