Announcement

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

    Problems with viewFile and downloadFile in 8.0

    Hi,

    We have functionality to view and download files which works fine in 6.5.1. This is usually what we see in the logs during these operations:

    Code:
    2011-04-01 16:25:28,835 INFO  [STDOUT] === 2011-04-01 16:25:28,835 [0-13] INFO  DSResponse - DSResponse: Map with 3 keys
    This is then followed by the file being delivered successfully.

    However, with 8.0, we see this in the logs and the file is delivered as a 0-byte file?

    Code:
    2011-04-01 16:37:45,577 INFO  [STDOUT] === 2011-04-01 16:37:45,577 [80-4] INFO  DSResponse - DSResponse: Map with 3 keys
    2011-04-01 16:37:45,577 INFO  [STDOUT] === 2011-04-01 16:37:45,577 [80-4] WARN  DSResponse - Attempted to call getRecord() on a DSResponse with null DataSource
    2011-04-01 16:37:45,577 INFO  [STDOUT] === 2011-04-01 16:37:45,577 [80-4] WARN  RPCManager - dsResponse.getRecord() returned null when attempting to process a data member of type java.util.HashMap. Can't continue.
    Does that give you enough info to provide guidance or is there more debug output you would need? If you need more debug, can you please tell me how to provide greater debug output for DSResponse and RPCManager classes since it appears they are not controlled by a normal log4J configuration.

    #2
    This suggests that you've created a DSResponse, didn't call setDataSource(), and provided data where we couldn't understand how to get the stream.

    First, try actually calling dsResponse.setDataSource().

    Second, explain what the data was that you provided, including the InputStream, and show the DataSource definition.

    Comment


      #3
      Thanks, I added dsResponse.setDataSource() and that fixed the problem.

      Strange, why has this never been needed in the past for any operation including viewFile or downloadFile. But, it is necessary now? Just curious.

      Comment


        #4
        Not clear, we'd need an answer to the further questions to comment.

        Comment


          #5
          Ok, well here is the code. I definitely had to do some hack-ish things to get this to work in our environment a few years ago because of difficulties arising from our use of document.domain, https, and hiddenFrame transport.

          If there is some new and better way to achieve this, I could give it a try. But, this took a lot of work to get this right back then.

          [CODE]
          dsRequest.setDownloadFieldName("attachedFile");
          dsRequest.setDownloadFileName(anBO.getAttachedFileName());
          Map responseMap = new HashMap();
          responseMap.put("attachedFile" + "_filename", anBO
          .getAttachedFileName());
          responseMap.put("attachedFile" + "_filesize", anBO
          .getAttachedFileSizeInBytes());
          responseMap.put("attachedFile", new ByteArrayInputStream(anBO
          .getAttachedFile()));
          dsResponse.setData(responseMap);

          dsRequest.context.response.setHeader("Pragma", "private");
          dsRequest.context.response.setHeader("Cache-Control",
          "private, must-revalidate");

          [/CODE

          Comment


            #6
            It also looks like DSResponse.setDataSource() is not a valid method in 6.5.1? Do we need some version specific logic to use this fix only in 8.0 ?

            Comment


              #7
              Hello,

              We have exactly the same problem, but your answer is not sufficient for us to solve the problem.
              Could you for example complete the codegiven by senordhuff ?
              Thanks in advance

              Comment


                #8
                Hi, in addition to the code I provided, I've added the only other relevant code that I think you might need based on this thread. Let me know if you are looking for something else?

                Code:
                DataSource ds = dsRequest.getDataSource();
                			
                //4/1/11..needed to add this for smartclient 8.0
                dsResponse.setDataSource(ds);
                
                
                dsRequest.setDownloadFieldName("attachedFile");
                dsRequest.setDownloadFileName(anBO.getAttachedFile Name());
                Map responseMap = new HashMap();
                responseMap.put("attachedFile" + "_filename", anBO
                .getAttachedFileName());
                responseMap.put("attachedFile" + "_filesize", anBO
                .getAttachedFileSizeInBytes());
                responseMap.put("attachedFile", new ByteArrayInputStream(anBO
                .getAttachedFile()));
                dsResponse.setData(responseMap);
                
                dsRequest.context.response.setHeader("Pragma", "private");
                dsRequest.context.response.setHeader("Cache-Control",
                "private, must-revalidate");

                Comment


                  #9
                  Thanks, that's what I did, but the problem seems to be the download_filename. I've made exactly like in your code, the string is not empty but when i look in the RPC console, this field is null, as I explained it in the thread :

                  http://forums.smartclient.com/showthread.php?t=16915

                  Comment


                    #10
                    I'm not sure I'm going to be much more help since the code snippet works in our environment. Your post references "download_filename" whereas my code references "attachedFile_filename". Is that significant ? If not, this may be a support issue for Isomorphic.

                    Comment


                      #11
                      This problem was due to a partially read of the InputStream from the server and is now solved. Thank you very much for your help.

                      Comment

                      Working...
                      X