【发布时间】:2021-02-04 10:58:27
【问题描述】:
我正在使用以下代码将 S3 对象解析为 Base64 字符串。
InputStream is = s3Object.getObjectContent().getDelegateStream();
byte[] bytes = IOUtils.toByteArray(is);
String base64Data = Base64.getEncoder().encodeToString(bytes); //Java Util lib.
此代码适用于文本和 pdf 文件。但是在转换图像文件时出现错误 MIME type not supported。
我还尝试使用 AWS 和 Apache Commons Base64 库。还是不行。
Base64.encodeAsString(bytes) //AWS
Base64.encodeBase64String(bytes) //Apache Commons
【问题讨论】:
标签: java spring amazon-web-services spring-boot amazon-s3