amazon-web-services - aws s3 - 将目录及其子目录上传为 s3 存储桶
解决方案
您是否尝试将目录结构上传到 s3?
然后你可以用 CLI 试试这个:
aws s3 sync . s3://mybucket
https://docs.aws.amazon.com/cli/latest/reference/s3/sync.html
您也可以通过编程方式实现此目的:
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