I’m using Primefaces 3.0.RC1 and on a form I have a <p:fileUpload mode="advanced" auto="true"> component. This has a fileUploadListener that is writing a copy of the temp file to disk.
The issue is (when uploading a file everything runs fine) that if while the file is being written to disk the user clicks the “Cancel” button, the file may already be partially written to the disk, but I need to be able to delete it at that point. Is there an event fired when the user clicks cancel?
EDIT: To clarify, the cancel button is still visible (and clickable) while the file upload event handler is executing. The issue is only if the user clicks cancel at this point. Clicking cancel while the file is still being uploaded to the server is fine.
I recommend you to set up a dedicated temporary directory to receive file uploaded thanks to the
uploadDirectoryparameter ofFileUploadFilterin yourweb.xml:I guess your code already move fully uploaded files to its definite location.
I propose you configure a regular job (with Quartz for instance) to remove any file older than more than one hour (or a configurable timeout) from the upload directory.