6 Replies Latest reply on Mar 25, 2010 6:24 PM by Ravi Kiran Bhaskar

    fileupload temp directory

    Ravi Kiran Bhaskar Newbie


              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


              <display-name>RichFaces Filter</display-name>


              <servlet-name>Faces Servlet</servlet-name>


      Any help is greatly appreciated


      Ravi Kiran Bhaskar

        • 1. Re: fileupload temp directory
          David Hibbs Newbie

          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)



          • 2. Re: fileupload temp directory
            Ravi Kiran Bhaskar Newbie

            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 Master

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

              • 4. Re: fileupload temp directory
                Ravi Kiran Bhaskar Newbie

                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




                Kindly let me know what you find



                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 Master

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


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


                  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
                    Ravi Kiran Bhaskar Newbie

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


                    Ravi Kiran Bhaskar