Amazon s3 Folders Problem

后端 未结 5 1959
逝去的感伤
逝去的感伤 2020-12-10 08:52

I need off help regarding amazon s3 with folders,

The problem i get with the Amazon s3 class by undesigned is it doesnt support folders, it will only show you the fu

5条回答
  •  没有蜡笔的小新
    2020-12-10 09:30

    I don´t know if this response it will be usefull after so long, but here we go:

    To resolve this problem you have to do this in java:

                List files = s3client.listObjects(bucket.getName()).getObjectSummaries();
                for (S3ObjectSummary file : files) {
                    if (file.getKey().endsWith("/"))
                        System.out.println("----" + file.getKey() + " (ES CARPETA)");
                    else 
                        System.out.println("----" + file.getKey() + " NO NO NO");
                }
    

    With the method "endsWith("/")" you can detect if the S3ObjectSummary is a folder or not.

    Hope this can helps someone.

    Mike

提交回复
热议问题