简体   繁体   English

如何使用 Java 将文件夹上传到 AWS S3?

[英]How can I use Java upload a folder to AWS S3?

I checked the document and the code examples.我检查了文档和代码示例。 However, I just found the way to upload a file.但是,我刚刚找到了上传文件的方法。 If I set the file path be a folder, the program would return exception:如果我将文件路径设置为文件夹,程序将返回异常:

Exception in thread "main" com.amazonaws.SdkClientException: Unable to calculate MD5 hash: /path/to/folder (Is a directory)

I noticed that C# code example has a way to upload folder, but Java doesn't.我注意到 C# 代码示例有一种上传文件夹的方法,但 Java 没有。 Does it mean Java cannot upload folder to AWS S3?这是否意味着 Java 无法将文件夹上传到 AWS S3?

The Amazon S3 API only supports uploading one object per API call. Amazon S3 API 仅支持每个 API 调用上传一个对象。 There is no API call to upload a folder.没有 API 调用来上传文件夹。

Your code would need to loop through each file in the folder and upload them individually.您的代码需要遍历文件夹中的每个文件并单独上传它们。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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