2 Replies Latest reply on Jun 1, 2011 4:16 PM by Val Sw

    FileUpload tempfile delete when?

    Marco Röösli Newbie

      if I use:


      <component class="org.jboss.seam.web.MultipartFilter">
        <property name="createTempFiles">true</property>
        <property name="maxRequestSize">1000000</property>
      </component>



      it will create tempFiles but when will this filed be removed? Is that depending on the session? or on the operating system how it handle temp files?


      Thx for your help


      Greetz Marco



        • 1. Re: FileUpload tempfile delete when?
          Vinícius Fernandes Newbie

          I wanna know this too. More than each, I don't know where is the tempfile.

          • 2. Re: FileUpload tempfile delete when?
            Val Sw Expert
            I think you need to delete it after your processing is done... item.getFile() will give you the complete file name

            Here is sample which I have used some time back...check where deleteTempFile(File f) is called..

            Let me know if this helps..

            public void listener(UploadEvent event) throws Exception{         
                    UploadItem item = event.getUploadItem();
                    file = new FileUpload();
                    file.setFileName(FilenameUtils.getName(item.getFileName()));
                    ...
                    blob=null;
                    //Add Content type
                    String fileType;
                    int extDot = item.getFileName().lastIndexOf('.');
                      if(extDot > 0){
                           String extension = item.getFileName().substring(extDot +1);
                           if("bmp".equals(extension)){
                                fileType="image/bmp";
                           }
                           ...
                           file.setFileType(fileType);               
                      }
                      
                      fileWrapper.getFileList().add(file);
                     uploadsAvailable--;       
                     ...
                    
                      if (item.isTempFile()) {
                           deleteTempFile(item.getFile());
                      }
            }

            private void deleteTempFile(File f) throws SecurityException{                    
                 f.delete();
            }