6 Replies Latest reply on Mar 25, 2010 6:24 PM by b_ravi_kiran

    fileupload temp directory

    b_ravi_kiran

      Hello,

              I have been using Richfaces 3.3.2 on Glassfish server hosted on a solaris server. Whenever I upload files using rich:fileupload I see the original files being stored to the '<glassfish install dir>/domains/<domain name>/config' folder. I also see '*.upload' files in the '/var/tmp'. I dont want the files in the config folder, is there any setting or am I  doing anything wrong ? I have the following filter in the web.xml

       

      <filter>
              <display-name>RichFaces Filter</display-name>
              <filter-name>richfaces</filter-name>
              <filter-class>org.ajax4jsf.Filter</filter-class>
              <init-param>
                <param-name>enable-cache</param-name>
                <param-value>false</param-value>
              </init-param>
              <init-param>
                  <param-name>createTempFiles</param-name>
                  <param-value>true</param-value>
              </init-param>
              <init-param>
                  <param-name>maxRequestSize</param-name>
                  <param-value>20000000</param-value>
              </init-param>   
          </filter>

       

          <filter-mapping>
              <filter-name>richfaces</filter-name>
              <servlet-name>Faces Servlet</servlet-name>
              <dispatcher>REQUEST</dispatcher>
              <dispatcher>FORWARD</dispatcher>
              <dispatcher>INCLUDE</dispatcher>
              <dispatcher>ERROR</dispatcher>
          </filter-mapping>

       

      Any help is greatly appreciated

       

      Ravi Kiran Bhaskar

        • 1. Re: fileupload temp directory
          sage.sam

          I don't know of a specific way to change where the files go by default; after all, it would need to be something platform independent.  I can, perhaps, provide you some options.

           

          Depending on your size limitation, server capacity and load, etc. you can consider setting createTempFiles=false on the tag.  This will make the file data available to the listener only as byte[].

           

          As an alternative, you can add a listener on your fileupload control and simply immediately move the file where you want it to go.  You do this by specifying fileUploadListener="#{yourComponent.yourListener"} on the tag, where yourMethod has a signature

           

          public void yourListener(UploadEvent event)

           

          HTH

          • 2. Re: fileupload temp directory
            b_ravi_kiran

            I cannot use createTempFiles=false as the files being uploaded are large number of high resolution photos which will eat the systems memory. Yes I do have the fileUploadListener in my backing bean which moves it to a folder and then resizes it and places the resized image in another folder. However it still creates these files in the glassfish's config folder (which by the way will be the current working directory for all applications as glassfish starts from this server)

            • 3. Re: fileupload temp directory
              ilya_shaikovsky

              can't reproduce under tomcat and RF 3.3.3 snapshots. Will check additionally under glassfish also.

              • 4. Re: fileupload temp directory
                b_ravi_kiran

                Hello Mr.Shaikovsky,

                                   I did check with 3.3.3.CR1 also  rich:fileupload still saves uploaded original files to glassfish's  config folder. To make your testing a bit easier I have attached the  backing bean, web.xml, 3 JSPs. Iam using STATE_SAVING_METHOD as server  and my faces-config.xml has the following. Note that I use ajax  keepalive for the uploaderBean (see galleryMain.jsp), galleryMain.jsp  includes tabbedPanel.jsp which inturn includes richMediaUpload.jsp

                 

                <managed-bean>
                         <managed-bean-name>uploaderBean</managed-bean-name>
                          <managed-bean-class>com.wpni.gb.managed.beans.MediaUploadBean</managed-bean-class>
                         <managed-bean-scope>request</managed-bean-scope>
                         <managed-property>
                             <property-name>galleryView</property-name>
                             <value>#{galleryView}</value>
                         </managed-property>
                         <managed-property>
                             <property-name>galleryService</property-name>
                             <value>#{galleryService}</value>
                         </managed-property>
                         <managed-property>
                             <property-name>properties</property-name>
                             <value>#{gbProperties}</value>
                         </managed-property>       
                     </managed-bean>

                 

                Kindly let me know what you find

                 

                Thanks,


                Ravi Kiran Bhaskar
                Lead Developer
                Washington Post Digital
                1150 15th Street NW, Washington, DC 20071
                washingtonpost.com | mobile.twp.com

                • 5. Re: fileupload temp directory
                  ilya_shaikovsky

                  We found the code which caused cration of the files in config folder:

                   

                  File toResizeFile = new File(item.getFileName());
                  FileOutputStream stream = new FileOutputStream(toResizeFile);
                  stream.write(bytes);
                  

                   

                  item.getFileName() returns just name of the file ("somepicture.jpg"). So it's created in current application working dir. And as you could check with System.getProperty("user.dir") - GlassFish has configs folder as working dir.

                  • 6. Re: fileupload temp directory
                    b_ravi_kiran

                    Yes Mr.Shaikovsky you are abosultely right. That was a brain fart on my end. sorry for posting non-richfaces issue.

                     

                    Ravi Kiran Bhaskar