【问题标题】:How to Download all images(.jpg) files from a aws s3 bucket如何从 aws s3 存储桶下载所有图像(.jpg)文件
【发布时间】:2020-07-23 04:47:35
【问题描述】:

我正在尝试下载存储在存储桶内的 aws s3 文件夹中的图像,并在我的前端显示这些图像。问题是我一次可以下载 1 张图片。我想一次性下载所有图像,然后显示在我的反应 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);  
 }

【问题讨论】:

    标签: reactjs spring-boot amazon-s3


    【解决方案1】:

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

    【讨论】:

    • 谢谢。我可以这样做,但是 aws sdk 对我来说是新的。在上面的代码中,byte[] 返回类型可以直接在 UI 中再现为图像。但仅适用于单个图像。寻找通过一些 aws 对象发送图像文件列表的方法
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-09-06
    • 2015-11-02
    • 1970-01-01
    • 1970-01-01
    • 2021-05-23
    • 1970-01-01
    • 2017-10-19
    相关资源
    最近更新 更多