2 Replies Latest reply on Jun 11, 2011 10:09 PM by Michael George

    File Upload not working with getData()

    Michael George Newbie

      I was successful in getting rich:fileUpload to work with getFile(), but I would prefer (for security reasons) to use the getData() method instead of getFile() . I've tested and verified in a mini-project that the createTempFiles param is set to FALSE (and removed the tempFilesDirectory param) inside web.xml. However, event.getUploadItem().getData() is returned as null. I did notice too that the isTempFile() call remains TRUE regardless of how I set my web.xml context param (i.e. either true/false has no effect on the isTempFile() property). Here's what my code looks like...

       

      home.xhtml

      <rich:fileUpload fileUploadListener="#{myAppView.fileUploadListener}"

          id="upload"

          maxFilesQuantity="5"

          immediateUpload="false"

          acceptedTypes="jpg, gif, png, bmp" allowFlash="false">

      </rich:fileUpload>

       

       

      Back End Bean

      public void fileUploadListener(UploadEvent event) throws Exception {

      log.info("INSIDE fileUploadListener - " + event.getUploadItem()..getData() + " | " + event.getUploadItem().isTempFile());

      }

       

      Output

      INSIDE fileUploadListener - null | false

       

      web.xml

      <context-param>
      <param-name>createTempFiles</param-name>
      <param-value>false</param-value>
      </context-param>

       

      <context-param>
      <param-name>maxRequestSize</param-name>
      <param-value>1024000</param-value> 
      </context-param>

       

       

      Is setting the createTempFiles context param inside web.xml to false not the correct way to retrieve a populated getData() property (where isTempFile() returns as false)?

       

      How do I configure my web app to successfully use the event.getUploadedItem().getData() method?

       

      Any help would be greatly appreciated. Thanks.

       

       

      Using: JSF 1.2, Facelets 1.1.14, RichFaces 3.3.3, Win XP 32 and Win 7 64-bit, IE and FF, Eclipse Helios, Tomcat 6, Java 1.6