HLuploadDirDotNet
Upload a Directory
You can use the TransferUtility
class to upload an entire directory. By default, the API uploads only the files at the root of the specified directory. You can, however, specify recursively uploading files in all of the subdirectories.
To select files in the specified directory based on filtering criteria, specify filtering expressions. For example, to upload only the .pdf files from a directory, specify the "*.pdf"
filter expression.
When uploading files from a directory, you don't specify the key names for the resulting objects. Amazon S3 constructs the key names using the original file path. For example, assume that you have a directory called c:\myfolder
with the following structure:
Example
When you upload this directory, Amazon S3 uses the following key names:
Example
Example
The following C# example uploads a directory to an Amazon S3 bucket. It shows how to use various TransferUtility.UploadDirectory
overloads to upload the directory. Each successive call to upload replaces the previous upload. For instructions on how to create and test a working sample, see Running the Amazon S3 .NET Code Examples.