gpt4 book ai didi

java - 如何使用亚马逊s3路径在java中列出亚马逊s3文件夹

转载 作者:行者123 更新时间:2023-12-02 13:19:04 24 4
gpt4 key购买 nike

我正在使用 Apache Spark 来解析文件。我有 Amazon S3 路径s3n://my-bucket/amazone-folder/如何列出使用此路径的所有文件和子文件夹。

最佳答案

AWS Java-SDK documentation有可用于此目的的 API 详细信息:

Provides an easy way to iterate Amazon S3 objects in a "foreach" statement. For example:

for ( S3ObjectSummary summary : S3Objects.withPrefix(s3, "my-bucket", "photos/") ) {
System.out.printf("Object with key '%s'\n", summary.getKey());
}

The list of S3ObjectSummarys will be fetched lazily, a page at a time, as they are needed. The size of the page can be controlled with the withBatchSize(int) method.

这是另一个教程解释 how to work with AWS Java SDK

关于java - 如何使用亚马逊s3路径在java中列出亚马逊s3文件夹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43659417/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com