Announcement Announcement Module
Collapse
No announcement yet.
Multipart File Upload Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • #16
    Yeah,
    So you created separate properties in the domain object to get hold of the name and type of file.

    Good, I tried this and it works fine.
    But I really think you should first try my earlier suggestion: eliminate the action state and put the <evaluate .../> upload logic directly in the view-state transition.
    Is it required to wrap my action inside the transition itself?
    As i said in my last post, that from the view-state I navigate to the action-state where I invoke this action to upload my file.

    Anyway, it works fine now.. the problem was with the multipart form.

    Thanks a lot for the suggestions.
    Cheers
    DeepEdward

    Comment


    • #17
      Glad that helped you. What I was suggesting was to use only the view state and put your upload logic in the view state transition subelement:
      Code:
      <view-state id="uploadVIew" model="myBean">
        <transition on="yourUploadEvent" to="success">
          <evaluate expression="myFormAction.fileUpload(myBean)"/>
        </transition>
      </view-state>
      Doing that way your method fileUpload() will be called after the binding and in the same request so you can use directly the MultipartFile (like you did in your original code). The difference between this approach (with only the view) and your original approach (with a view and an action state) is that when you execute the action state you are in a different request than the first one (because of the redirect after post that the swf is doing under the scene). Because of that the multipartFile member has to be serialized and there appears to be the problem. If you specify it as transient it will not be serialized and when you'll access it in your method you'll get a nullpointer. So in order to get rid of the problem you have to avoid the serialization (specify transient on the multipartFile) and you have to access it when it has the value, in the first request (put your upload code in the view state like I said before).
      I have a tendency to be verbose because english is not my native language. Hope that I was clear enough.

      Comment


      • #18
        a little more information...

        I am having the same issue...and like deep says the file still get uploaded.

        Code:
        org.springframework.webflow.execution.repository.FlowExecutionRestorationFailureException: A problem occurred restoring the flow execution with key 'e1s5'
        	at org.springframework.webflow.execution.repository.snapshot.SerializedFlowExecutionSnapshotFactory.restoreExecution(SerializedFlowExecutionSnapshotFactory.java:82)
        	at org.springframework.webflow.execution.repository.snapshot.AbstractSnapshottingFlowExecutionRepository.restoreFlowExecution(AbstractSnapshottingFlowExecutionRepository.java:89)
        	at org.springframework.webflow.execution.repository.impl.DefaultFlowExecutionRepository.getFlowExecution(DefaultFlowExecutionRepository.java:104)
        	at org.springframework.webflow.executor.FlowExecutorImpl.resumeExecution(FlowExecutorImpl.java:152)
        	at org.springframework.webflow.mvc.servlet.FlowHandlerAdapter.handle(FlowHandlerAdapter.java:173)
        	at org.springframework.webflow.mvc.servlet.FlowController.handleRequest(FlowController.java:172)
        	at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
        	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:875)
        	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:809)
        	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:571)
        	at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:501)
        	at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
        ....
        
        Caused by: org.springframework.webflow.execution.repository.snapshot.SnapshotUnmarshalException: IOException thrown deserializing the flow execution stored in this snapshot -- this should not happen!
        	at org.springframework.webflow.execution.repository.snapshot.SerializedFlowExecutionSnapshot.unmarshal(SerializedFlowExecutionSnapshot.java:100)
        	at org.springframework.webflow.execution.repository.snapshot.SerializedFlowExecutionSnapshotFactory.restoreExecution(SerializedFlowExecutionSnapshotFactory.java:80)
        ...
        Caused by: java.io.FileNotFoundException: C:\dev\apps\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\work\Catalina\localhost\mobolus\upload_c82342c_11aef8b3cda__8000_00000005.tmp (The system cannot find the file specified)
        	at java.io.FileInputStream.open(Native Method)
        	at java.io.FileInputStream.<init>(FileInputStream.java:106)
        	at org.apache.commons.fileupload.disk.DiskFileItem.readObject(DiskFileItem.java:691)
        ...
        As seen in the last stacktrace, it looks like there is some kind of error in the org.apache.commons.fileupload.disk.DiskFileItem.re adObject()

        I tried searching for this issue but I it seems its related to webflow in some way. I am not sure how to proceed.

        Comment


        • #19
          Sorry I missed page 2. I didn't see that you had already resolved this.

          Originally posted by DeepEdward View Post
          Yeah,
          Anyway, it works fine now.. the problem was with the multipart form.
          Please explain this. What did you do to fix the multipart form.

          Comment


          • #20
            Ok, nevermind...somebody (me) needs to read a little more carefully and not skim so much. I will try it out.

            Comment


            • #21
              Thanks fanfy for the explanation as it gave me a better approach to this.

              And your being verbose is good as it gave a detailed explanation

              DeepEdward

              Comment


              • #22
                Originally Posted by testing123
                I am having the same issue...and like deep says the file still get uploaded.
                Have a look at the previous posts.. thats gonna help you out..

                Comment


                • #23
                  Thanks fanfy!

                  I had this same problem. Your explanation was good - and the solution worked for me too.

                  Comment


                  • #24
                    resolve

                    public void fileUpload(Object command) {
                    log.info("FILE UPLOAD");
                    String dir = "z://FileUpload//File_Repository//";
                    try {
                    byte buf[] = new byte[1024 * 4];
                    Portfolio bean = (Portfolio) command;

                    new File(dir).mkdirs();
                    log.info("Creating Directory");

                    File file = new File(dir, bean.getFile().getOriginalFilename());

                    FileOutputStream output = new FileOutputStream(file);
                    output.write(bean.getFile().getBytes());

                    try {
                    InputStream input = bean.getFile().getInputStream();
                    try {
                    while (true) {
                    int count = input.read(buf);
                    if (count == -1) {
                    break;
                    }
                    output.write(buf, 0, count);
                    }
                    } finally {
                    input.close();
                    }
                    } finally {
                    output.close();
                    bean.setFile(null);
                    }
                    } catch (Exception e) {
                    e.printStackTrace();
                    }
                    }

                    Comment


                    • #25
                      Thanks!!! The suggested appraoch helped me to resolve the file (PDF) upload issue using webflow.

                      Comment


                      • #26
                        Solved for us

                        The issue was solved when we set bind="false" on transition state.

                        Comment


                        • #27
                          Check this link first for simple upload file
                          http://www.ioncannon.net/programming...pload-example/
                          Then Multi Part
                          http://www.caucho.com/resin-3.0/jsp/.../multipart.xtp

                          Comment

                          Working...
                          X