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

发布于 2024-12-04 16:14:38 字数 988 浏览 1 评论 0原文

我在 Tomcat 服务器上使用 Richfaces(在 Linux 下)。我将上传程序更改为 createTempFiles 以节省一些内存。默认情况下,它现在将文件加载到“35f1968e-13267391427--71a74431089769578330705.upload”等文件中的../tomcat/temp/。不幸的是 Tomcat/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>

所以如果我无法更改目录(除非某人知道一种方法) - 使用后如何删除临时文件?谢谢!

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>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? Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

萌能量女王 2024-12-11 16:14:38

您上传的文件有多大?无论如何,丰富的组件将上传的文件存储在临时文件夹中。您还可以检查 item.isTempFile() 是否存在并从文件操作中删除。并且您不需要初始化到 DD 中。

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

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

onClear 可以添加这个事件。

    public void resetFileUpload(UploadEvent event) {

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

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;
    }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文