1 Reply Latest reply on Oct 9, 2006 7:55 AM by Richard Leherpeur

    Tomahawk fileUpload tag

    Richard Leherpeur Novice


      I'm using the fileUpload tag from Tomahawk library. I followed the setup explained in the wiki and the download part seems to work fine.
      I get a .tmp (the name of the file is like upload__639ed4a2_10e27a79cd0__7fff_00000003.tmp) file on the upload directory I setup.

      The UploadedFile object contains the right data with the name of the original file.
      I was expecting the tmp file to be renamed after the download is complete. But it seems it is not happening that way. I keep having a .tmp file in the upload directory.
      On the other hand, I don't really have a way to connect that .tmp file to any file object in java.
      Do I miss something? Is the file writing somewhere else after the upload succeeded and the .tmp file is just garbage?

      Thanks for you help,


        • 1. Re: Tomahawk fileUpload tag
          Richard Leherpeur Novice

          So the tomahawk inputFileUpload tag uses commons-fileupload library.
          The uploaded file is uploded and stored either in memory or on the disk as a tmp file.
          This is up to the user to write the temporary file into a permanent file.
          The FileItem.write(File file) methods will do that but we have to call the write method on the fileItem.

          So this is the part that was missing in the wiki (http://wiki.jboss.org/wiki/Wiki.jsp?page=Alternative_FileUpload) for the use of the inputFileUpload tag.

          In the upload method of the uploadAction bean, I added to following:

          File file = new File("/upload/" + + uploadFile.getName());
           ServletRequest multipartRequest = (ServletRequest)facesContext.getExternalContext().getRequest();
           if (multipartRequest != null) {
           MultipartRequestWrapper mpReq = (MultipartRequestWrapper)multipartRequest;
           FileItem fileItem = mpReq.getFileItem("uploadForm:uploadFile");
           try {
           } catch (Exception e) {

          Which rename the tmp file info the appropriate file.