0 Replies Latest reply on Dec 2, 2015 11:08 AM by stevemei RSS
    stevemei Newbie

    How can I implement a service that streams binary data to the client?

    I would like to provide the browser with a hyperlink that when the user clicks on it the browser calls a ThingWorx service (via the URL) where the service streams ZIP file content to the browser. The response will need the correct HTTP headers so that the browser understands that the content is a ZIP file and allows the user to save or open the ZIP file. I can't use the file download services that ThingWorx provides because they require that the file exist on the server. In my case the file doesn't exist, but will be streamed from an external REST endpoint and I don't want to store the ZIP file content on the ThingWorx server before it can be downloaded. But rather I want the ThingWorx service to stream the ZIP to the browser while it reads it from the external REST endpoint.

     

    Is this possible? How is it done? Or is there another mechanism that allow for a user experience where they click on a hyperlink and get normal ZIP file download behavior where the ThingWorx is the server that provides the ZIP file content? I don't want the browser going directly to the external system to download the ZIP file as that external system may not be accessible. I haven't investigated using Web Sockets, but could Web Sockets be used to solve this?