facebook

Debug JSF Tomahawk File upload file name and location urgent

  1. MyEclipse IDE
  2.  > 
  3. Off Topic
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #253623 Reply

    I am running the example myfacesrlc\src\org\apache\myfaces\examples\misc\FileUploadForm.java
    with the following settings on WindowsXP and Java 1.5 and Tomcat-5.5.17 and observed the following
    when using the Tomahawk ext to upload files: Tomahawk seems to have its own ideas about what
    to name the files when uploaded. I need access to the files to manipulate them after upload
    and need to know what they are named and where they are.

    If I upload a file like abc.jpg it reports back fine in the return page as the correct image and the right name,
    but I need to fix two things and I can’t seem to trap for them in the debugger to help figure out where to make
    the changes.

    1. The file name is always changed to upload_A NUMBER.tmp like this upload_00000007.tmp rather than the
    real name of the file.

    2. What ever directory name that I set in the web.xml for uploadRepositoryPath ends up on the root
    of my C drive rather than the root of the application?
    I understand from reading that there may be some involvement with the java.io.tmpdir but I am not sure.

    It would be VERY helpful if some one can tell me how to make it write to a relative directory in the application
    context off the application root in tomcat, and how do I best make it write the file name that I want the first time
    or at least re-copy it to the correct directory with the right name.
    I have tried to set the debugger to catch when the change is happening but I have not been successful.

    with WebRoot\fileupload.jsp

    <h:form id=”form1″ enctype=”multipart/form-data” >
    <h:outputText value=””/>
    <h:outputText value=”#{example_messages[‘fileupload_gimmeimage’]} “/>
    <t:inputFileUpload id=”fileupload”
    accept=”image/*”
    value=”#{fileUploadForm.upFile}”
    storage=”file”
    styleClass=”fileUploadInput”
    required=”true”
    maxlength=”200000″/>
    <h:message for=”fileupload” showDetail=”true” />
    <f:verbatim><br></f:verbatim>
    <h:outputText value=”#{example_messages[‘fileupload_name’]}”/>
    <h:inputText value=”#{fileUploadForm.name}”/>
    <h:commandButton value=”#{example_messages[‘fileupload_button’]}” action=”#{fileUploadForm.upload}” />
    </h:form>

    web.xml …
    <filter>
    <filter-name>extensionsFilter</filter-name>
    <filter-class>org.apache.myfaces.webapp.filter.ExtensionsFilter</filter-class>
    <init-param>
    <description>Set the size limit for uploaded files.
    Format: 10 – 10 bytes
    10k – 10 KB
    10m – 10 MB
    1g – 1 GB</description>
    <param-name>uploadMaxFileSize</param-name>
    <param-value>100m</param-value>
    </init-param>
    <init-param>
    <description>Set the threshold size – files
    below this limit are stored in memory, files above
    this limit are stored on disk.

    Format: 10 – 10 bytes
    10k – 10 KB
    10m – 10 MB
    1g – 1 GB</description>
    <param-name>uploadThresholdSize</param-name>
    <param-value>1k</param-value>
    </init-param>
    <init-param>
    <description>Set the path where the intermediary files will be stored.</description>
    <param-name>uploadRepositoryPath</param-name>
    <param-value>/uploadLocation</param-value>
    </init-param>
    </filter>

    Thank you very much in advance.

    #253648 Reply

    Riyad Kalla
    Member

    Moving to OT > Soft Dev

    #253661 Reply

    Close issue.
    The answer is to use
    value=”#{fileUploadForm.upFile}”

    sets the value of file name in the backing bean. upFile is basically a setter for a field of type UploadedFile.

    Use the following to grab the input stream
    upFile.getInputStream()
    That way you don’t have to worry about the file name.

    #253674 Reply

    Riyad Kalla
    Member

    MDOT, Thank you for following up for other users that are trying to do the same work, very helpful.

Viewing 4 posts - 1 through 4 (of 4 total)
Reply To: Debug JSF Tomahawk File upload file name and location urgent

You must be logged in to post in the forum log in