function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
de54874de54874 

API's to stream binary data on browser

Do we have any API's in force.com to stream byte stream to browser? In other laguages we normally have I/O API's to work with output streams etc, is there anything like that in apex?

sfdcfoxsfdcfox
There is a "streaming API", but it only applies to streaming events (e.g. new records being created or records being updated). There isn't a way to manipulate bytes directly in Apex Code or monitor inputs server-side (a so-called "long-running transaction", such as Comet).

The best that you can do without messing with the Streaming API is to periodically poll the server for new data. Regardless, binary data can only be sent indirectly, via base-64 encoding, since all output streams are utf-8 strings, not natural byte streams.