【发布时间】:2021-03-31 00:48:44
【问题描述】:
我正在尝试使用 minio 客户端从 S3 存储桶中读取文件。
https://docs.min.io/docs/java-client-quickstart-guide.html
我可以使用此客户端建立连接,也可以访问存储桶。现在,我需要访问存储桶中文件夹内的文件,但我不知道该怎么做。我想一旦我可以访问存储桶,我可以使用文件库列出文件名,但不能这样做。
文件路径:s3 bucket endpoint/4275/input/test.csv
代码:
public void listS3BucketObject() {
MinioClient minioClient =
MinioClient.builder()
.endpoint(s3BucketEndpoint)
.credentials(s3BucketAccessKey, s3BucketSecretKey)
.build();
String fileUrl = s3BucketEndpoint + "/" + "4275" + "/" + "input";
File[] fileList = new File(fileUrl).listFiles();
for(File file : fileList) {
System.out.println("File name: "+file.getName()); // getting null exception here
【问题讨论】: