I'm trying to compress the file in java before I upload the file with GZIPOutputStream
. Is there a way to just store the gzipped file in memory for the upload and not have it generate a gzipped file on the local computer?
Thanks!
I'm trying to compress the file in java before I upload the file with GZIPOutputStream
. Is there a way to just store the gzipped file in memory for the upload and not have it generate a gzipped file on the local computer?
Thanks!
Just connect the GZipOutputStream directly to the output stream and write. No file necessary.
Decorate content entity with GzipCompressingEntity
HttpPost httpPost = new HttpPost("https://host/stuff");
httpPost.setEntity(new GzipCompressingEntity(new FileEntity(new File("my.stuff"))));
CloseableHttpResponse response = httpclient.execute(httpPost);
try {
EntityUtils.consume(response.getEntity());
} finally {
response.close();
}
Solved this problem by writing to a temp file and doing a .deleteonexit on the temp file once the gzip uploading was done.
Thanks for the help!