Bug 65581 - add optional support in ZipArchiveFakeEntry to use a temp file
Summary: add optional support in ZipArchiveFakeEntry to use a temp file
Status: RESOLVED FIXED
Alias: None
Product: POI
Classification: Unclassified
Component: POI Overall (show other bugs)
Version: 5.0.x-dev
Hardware: All All
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-09-18 13:54 UTC by PJ Fanning
Modified: 2021-09-19 20:08 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description PJ Fanning 2021-09-18 13:54:17 UTC
Currently, ZipArchiveFakeEntry will read all the bytes of the file into memory unless there are more than 2GB (Integer.MAX_VALUE) - in which case it throws an error.

The workaround is to load the data from a java.io.File instead of an InputStream but this may not be obvious or straightforward.

Aim is to have a configurable value at which ZipArchiveFakeEntry creates a temp file (or an equivalent class).
Comment 1 PJ Fanning 2021-09-18 13:55:24 UTC
IOException("ZIP entry size is too large or invalid") is the existing exception
Comment 2 PJ Fanning 2021-09-18 20:09:27 UTC
added implementation using r1893421

Using this will mean all zip entries with greater than 50Mb decompressed data will be put in a temp file instead of kept in memory.
        ZipInputStreamZipEntrySource.setThresholdBytesForTempFiles(50000000);

This only affects users when they read files using Input Streams instead of reading directly from a java.io.File.
Comment 3 PJ Fanning 2021-09-19 20:08:30 UTC
ZipInputStreamZipEntrySource.setEncryptTempFiles(true); //also now supported