Skip to content
Advertisement

How to save/zip binary/octet-stream s3 content to zip

I am trying to add s3 bucket files into a zip. The files in the s3 bucket are in binary/octet-stream format.

When I run the below method

JavaScript

The IO Exception below is thrown when executing IOUtils.copy method

“exception”: “Premature end of Content-Length delimited message body (expected: 206,034; received: 0)”

Any suggestions on how I can handle this or what am doing wrong? Thank you.

Edit:- @LeeGreiner I am getting the InputStream like this:

JavaScript

Advertisement

Answer

You can use a ResponseTransformer to convert the response to an input stream:

JavaScript

My specific method is as follows (it assumes the s3 connection has already been created):

JavaScript

The resulting input stream can then be added to your zip file in the usual way.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement