[英]Upload folder including empty subfolders to S3 (with AWS Java SDK)
I try to upload a folder from my locale laptop to Amazon's S3. 我尝试将文件夹从我的语言环境笔记本电脑上传到Amazon的S3。 I use the following code with Amazon's Java SDK:
我将以下代码用于Amazon的Java SDK:
File folder = new File("c:/some/of/my/folders");
TransferManager tm = new TransferManager( AWS.getAwsCredentials() );
MultipleFileUpload upload = tm.uploadDirectory( "my-bucket", folder.getName(), folder, true );
upload.waitForCompletion();
tm.shutdownNow();
The actual upload works as expected and I can see my folder, subfolders and files on the web console of S3. 实际的上传按预期方式工作,我可以在S3的Web控制台上看到我的文件夹,子文件夹和文件。 But all empty folders (which contain no files or other folders) are missing.
但是缺少所有空文件夹(不包含任何文件或其他文件夹)。 How can I upload them to?
如何将它们上传到?
I know that S3 doesn't know "folders" and works with keys since it is no file system. 我知道S3不知道“文件夹”并且可以使用键,因为它不是文件系统。 But I can create "a folder" by uploading empty content (eg like here ).
但是我可以通过上传空白内容来创建“文件夹”(例如,如此处 )。 As far as I can see, the only solution for my problem would be to upload the folder like shown above and then iterate trough my folder looking for all empty folders and uploading them separately.
据我所知,解决我问题的唯一方法是像上图所示上载文件夹,然后遍历我的文件夹以查找所有空文件夹,然后分别上载它们。 Any other ideas?
还有其他想法吗?
You are right, s3 is a key-object map (not hierarchical). 没错,s3是关键对象映射(不是分层结构)。 Creating an empty (0 byte) object with a key ending in "/" should display in the S3 Management Console as a folder.
创建一个以“ /”结尾的键的空(0字节)对象应该在S3管理控制台中显示为文件夹。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.