从S3中读取Java中的压缩的ion内容

huangapple 未分类评论45阅读模式
英文:

read zipped ion content from s3 in java

问题

以下是翻译好的内容:

我有一个后端服务,它使用GZipOutputStream写入一个文件到S3,前端希望在其中显示ION内容。我尝试使用GZipInputStream来包装S3Object的getObjectContent()方法返回的InputStream,但似乎不起作用。

有人能帮忙吗?

使用GzipOutputStream生成压缩文件的代码

generateAndWriteInfo() {
 byte[] info = generateInfo();
 gzipOutputStream.write(info);
}

close() {
gzipOutputStream.close();
}

从S3读取的代码

S3Object result = client.getObject(bucket_name, key);
byte[] array = IOUtils.toByteArray(result.getObjectContent());
IonDatagram datagram = ios.newLoader().load(IOUtils.toByteArray(new GZIPInputStream(new ByteArrayInputStream(array))));
英文:

I have a backend service that writes a file created using GZipOutputStream to S3 and the front end wants to display the ION content in it. I tried using GZipInputStream to wrap the InputStream returned by the S3Object getObjectContent() method, but does not seem to be working.

Can anyone help here?

Code to generate zipped file using GzipOutputStream

generateAndWriteInfo() {
 byte[] info = generateInfo();
 gzipOutputStream.write(info);
}

close() {
gzipOutputStream.close();
}

code to read it from S3

S3Object result = client.getObject(bucket_name, key);
byte[] array = IOUtils.toByteArray(result.getObjectContent());
IonDatagram datagram = ios.newLoader().load(IOUtils.toByteArray(new GZIPInputStream(new ByteArrayInputStream(array))));

huangapple
  • 本文由 发表于 2020年4月8日 02:49:32
  • 转载请务必保留本文链接:https://java.coder-hub.com/61087263.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定