英文:
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))));
专注分享java语言的经验与见解,让所有开发者获益!
评论