Announcement

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

    Download file via RPCManager.sendRequest

    This question is a follow-up on this thread https://forums.smartclient.com/forum/technical-q-a/31034.

    It might be beneficial if I could use RPCManager.sendRequest() with the "downloadResult" option set to true to download a binary file using a non-SmartClient-server (in my case RubyOnRails). Right now the code below gives a console error (Uncaught TypeError: Failed to execute 'createObjectURL' on 'URL': Overload resolution failed).

    Code:
    isc.RPCManager.sendRequest({
      actionURL: 'file.pdf',
      downloadResult: true,
      httpMethod: 'GET',
      useSimpleHttp: true
    });
    I'm using the GET method here, but ideally this would also work with POST (that has to do with the way my server is set up).

    Right now, I'm simply using window.open() to do a GET request. This works, but it's harder to create the query string parameters than it is using the RPCManager.

    #2
    Hi Wally,

    rpcRequest.downloadResult is specific to the comm mechanism used with the SmartClient Server. There is no way for its behavior to "just work" without having the SmartClient Server.

    However, initiating a download from the browser is quite simple. There are multiple possible approaches with different benefits and drawbacks.

    We would recommend asking ChatGPT "what are the different ways to initiate file download in a browser using JavaScript, and what are the benefits and drawbacks of each?"

    Comment


      #3
      Thanks for the suggestion! The result from ChatGPT looks promising!

      Comment

      Working...
      X