如何从AWS S3存储桶下载所有图像(.jpg)文件

时间:2020-07-23 04:47:35

标签: reactjs spring-boot amazon-s3

我正在尝试下载存储在存储桶中的aws s3文件夹中的图像,并在前端显示图像。问题是我可以一次下载1张图片。我想一次下载所有图像,然后显示在我的React UI中。我在后端使用Springboot。下面是我的代码。

 public byte[] downloadUserProfileImage(int userProfileId) {
    String path = String.format("%s/%s",
            BucketName.PROFILE_IMAGE.getBucketName(),
            userProfileId);
    String filename = "profile_image.jpg";
    return fileStore.download(path, filename);  
 }

1 个答案:

答案 0 :(得分:0)

我还没有将Springboot与aws一起使用。但是在python中,我这样做了,因此在Java / springboot中,语法只会改变。 您需要遍历S3中的所有文件,获取这些文件的密钥,并且具有s3.download_file(...)的功能。 要遍历文件,请使用分页器-Check the documentation