简体   繁体   中英

aws s3 - upload a directory and its subdirectories as a s3 bucket

I try to transfer a directory and its sub-directories to an s3 bucket by code. In my case a sub-directory is a partition in the bucket. As in the picture: 在此处输入图片说明

Are you trying to upload your directory structure to s3?

Then you can try this with the CLI:

aws s3 sync . s3://mybucket

https://docs.aws.amazon.com/cli/latest/reference/s3/sync.html

You could also achieve this programatically:

TransferManager tm = new TransferManager(new ProfileCredentialsProvider());
MultipleFileUpload upload = tm.uploadDirectory(bucket, folder, new File(filePath), true);

try
{
    // Or you can block and wait for the upload to finish
    upload.waitForCompletion();
    LOGGER.debug("Upload complete.", bucket, folder);
}
catch (AmazonClientException amazonClientException)
{
    LOGGER.error("Unable to upload file, upload was aborted.", amazonClientException);
    throw amazonClientException;
}

https://docs.aws.amazon.com/sdk-for-java/v1/developer-guide/examples-s3-transfermanager.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM