Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to delete PrimeFaces UploadedFile temp file after processing?

PrimeFaces UploadedFile only exposes the InputStream, not the File itself. How can I delete it after processing the stream?

like image 784
Forty Avatar asked Aug 19 '12 05:08

Forty


1 Answers

PrimeFaces uses Apache Commons FileUpload under the covers for this. It will create the file as a temporary file and hence the file will already be automatically deleted if there are no open File nor InputStream references to it when the Java Garbage Collector runs.

So if you can make absolutely sure that you close the InputStream after processing (in the finally block!), then you don't need to worry about cleanup.

like image 68
BalusC Avatar answered Sep 23 '22 00:09

BalusC