简体   繁体   English

Richfaces fileUpload:如何设置临时文件的路径以及如何清理它

[英]Richfaces fileUpload: How to set path of temp files and how to clean it

I'm using Richfaces on an Tomcat Server (under linux). 我在Tomcat服务器(在Linux下)上使用Richfaces。 I changed the uploader to createTempFiles to save some ram. 我将上传器更改为createTempFiles来保存一些内存。 By default it now loads the files to ../tomcat/temp/ in files like " 35f1968e-13267391427--71a74431089769578330705.upload ". 默认情况下,它现在将文件加载到../tomcat/temp/中的文件中,例如“ 35f1968e-13267391427--71a74431089769578330705.upload ”。 Unfortunately Tomcat/Richfaces doesn't delete those files. 不幸的是,Tomcat / Richfaces不会删除这些文件。 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) 我尝试了以下配置,但没有进行任何更改( 错误报告 -如果我正确理解此配置,则在Richfaces的v3.3.3中不可用)

    <init-param>
        <param-name>createTempFiles</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? 因此,如果我不能更改目录(除非sb知道一种方法)-使用后如何摆脱临时文件? 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. 您还可以检查item.isTempFile()并从文件操作中删除。 And you need not initialize into the DD. 而且您无需初始化为DD。

public synchronized void fileUploadListener(UploadEvent event) {
        UploadItem item = event.getUploadItem();

        uploadedFile = item.getFile();
        isFileUploaded = true;
    }

onClear you can add this event. onClear您可以添加此事件。

    public void resetFileUpload(UploadEvent event) {

        LOGGER.info("Resetting the file uploaded");
        uploadedFile = null;
        isFileUploaded = false;
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM