Richfaces fileUpload: How to set path of temp files and how to clean it
I'm using Richfaces on an Tomcat Server (under linux). I changed the uploader to createTempFiles to save some ram. By default it now loads the files to ../tomcat/temp/ in files like "35f1968e-13267391427--71a74431089769578330705.upload". Unfortunately Tomcat/Richfaces doesn't delete those files. How may I enable this? And how can I change the location of the folder the files are saved in? I tried the configuration below and it didn't change anything (bug report - if I understand this correctly it is not available in v3.3.3 of Richfaces)
<init-param>
<param-name>creat开发者_JAVA技巧eTempFiles</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<description>
Set the path where the intermediary files will be stored.
</description>
<param-name>uploadRepositoryPath</param-name>
<param-value>uploadedfiles/</param-value>
</init-param>
So if I can't change the dir (except sb knows a way) - how to get rid of the temp files after using it? Thanks!
How big is the file you are uploading? anyway the rich component stores the uploaded file in the temporary folder. you can also check if item.isTempFile() and delete from the file action. And you need not initialize into the DD.
public synchronized void fileUploadListener(UploadEvent event) {
UploadItem item = event.getUploadItem();
uploadedFile = item.getFile();
isFileUploaded = true;
}
onClear you can add this event.
public void resetFileUpload(UploadEvent event) {
LOGGER.info("Resetting the file uploaded");
uploadedFile = null;
isFileUploaded = false;
}
精彩评论