veraPDF / veraPDF-library

Industry supported, open source PDF/A validation library
http://verapdf.org/software
GNU General Public License v3.0
268 stars 48 forks source link

Question regarding tmp-file #1420

Closed Lolf1010 closed 5 months ago

Lolf1010 commented 5 months ago

Hey, if i understand it correctly the Inputstream that is given to Parser.createParser is written into a temp-file and the library then reads from that file. Meaning that if i would parse a 1 MB InputStream a 1 MB temp-file would be temporarily exist.

I think the answer is no but just to make sure:

Thank you

Update: It appears that the classes are signed which means that its not easily possible to overwrite the InternalInputStream to change the directory. So i guess the only option would be to change the java-property.

Lolf1010 commented 5 months ago

Can you maybe make it configurable to define a sub-folder in the tmp-folder ?

bdoubrov commented 5 months ago

Normally small cached data is not written into tmp files and kept in memory. "Small" means < SeekableInputStream.MAX_BUFFER_SIZE. This is a private constant, which we can expose as one of the veraPDF configuration parameters.

Temporary files are always created by standard Java call File.createTempFile(String prefix, String suffix); . Again, we can use another version of this method File.createTempFile(String prefix, String suffix, File directory); and expose directory as yet another config parameter.

Would this work for your purposes?

Lolf1010 commented 5 months ago

Thanks for the response. The idea to use a different directory for the tmp-files was discussed at work - which is when i wrote this issue - but since then has been dropped. So the library works for our purposes. Feel free to reopen the issue / create a new one if you want to implement the configuration for the directory anyways ;)