Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

  • Getting dsRequest.getUploadedFiles() as null after uploading file in dynamic form.

    We are uploading pdf file from client side using "FileItem", and send the incoming file stream to a service using REST api. But seems that the file created from this stream is always corrupt. Tried to get the file "dsRequest.getUploadedFiles()" but it always comes out to be null always. Tried using dsRequest.getUploadedFile("fileName") but this also comes out to be null.

    SmartGwt Version: 6.1-p20170905/PowerEdition
    Browser: Google Chrome Version 74.0.3729.169 (Official Build) (64-bit)

    Client side, server side code and the ds.xml is attached.

    Thanks in advance.

    Attached Files

  • #2
    Whenever people report this, the problem is generally that there is a server-side system that receives the request before our code does, and breaks the upload (by reading the full request stream before we do, which means we aren't allowed to do it again).

    First, use your browser's built-in tools to verify that there is actually a file being uploaded. If there isn't, you have a client-side problem.

    If there is indeed a file in the request, remove any and all processing that happens before our servlet, including filter servlets or authentication systems. If you then see the file upload working, then you should investigate why these other frameworks are breaking file upload.

    Comment


    • #3
      Here is the request as i got from ISC comsole. We can see the file in bold being send in request. Please see if anything seems wrong.

      Last edited by sidharth1917; 29th Aug 2019, 21:10.

      Comment


      • #4
        See previous response:

        First, use your browser's built-in tools to verify that there is actually a file being uploaded. If there isn't, you have a client-side problem.
        The built-in tools can show you whether a file upload actually occurred. What you're looking at is just a JSON dump of the request data *aside from* the file.

        Also, once you've ascertained that a file is actually being submitted, you still have several steps to take on your own. Reread our first response if this is not clear.

        Comment


        • #5
          I think file is getting uploaded in the request. Its just that we are getting dsRequest.getUploadedFiles() as null.

          Screenshot is attached.

          Attached Files

          Comment


          • #6
            These are just the headers. If you do not know how to use built-in browser tools to view a file that has been uploaded, you can Google that for whichever browser you are using.

            Comment


            • #7
              And bear in mind, as we have repeated twice already now, once you've verified that a file is being uploaded, there are still steps for you to take on your own. Please do not write back a 4th time without taking the steps we have already given you. Thanks.

              Comment


              • #8
                I can see the pdf being uploaded on browser with all its encoded content. After that i have disabled all the filters in web.xml and there is no other code or processing that happens in between. We just try to get the file using dsRequest.getUploadedFile("filename"), but it happens to be null always.

                Is there any way we can connect remotely and debug the issue.
                Last edited by sidharth1917; 10th Jun 2019, 04:13.

                Comment


                • #9
                  We would highly recommend double-checking all the possibilities we mentioned - filter servlets or other intervening layers, such as firewalls or proxies that might cause a problem.

                  We’ve seen this exact issues raised many times before, and the resolution is always that there is a layer before SmartClient that discards the file.

                  Also, you mentioned in your most recent post that calling getUploadedFile() is null - please confirm that getUploadedFiles() is also not providing access to the file. Note that, by necessity, the file name we pass is just a placeholder, as some browsers don’t provide access to the true file name, hence getUploadedFiles() is the definitive test.

                  While you can debug all you like, next step would be to write a simple servlet that tries to access the uploaded file content. This will prove that the file is simply not available to our server libraries, so you can then go back to looking into the real cause.

                  Comment


                  • #10
                    I wrote a simple servlet and was able to receive the file in both dsRequest.getUploadedFile("filename") and dsRequest.getUploadedFiles(). The only uncommon thing is the dispacther servlet which is not getting called in this case. Can dispatcher servlet be blocking the uploaded file?. I dont think this is the case.

                    Comment


                    • #11
                      So when you told us you had eliminated all processing that happens between, that wasn't actually true, and you knew that?

                      We've told you several times that you need to look at all intervening processing and remove it, but it looks like you expect to be told this one more time: so yes, try removing the dispatcher servlet, whatever that is.

                      Comment


                      • #12
                        Any spring application won't work without dispatcher servlet. I tried removing it earlier also.
                        I have never worked with custom servlets before this, so didn't knew that when we create a custom servlet, the dispatcher servlet won't get called.

                        Comment

                        Working...
                        X