[ad_1]
I’m writing Chrome extension that is using NativeMessaging API to receive chunks of file generated in external application. Each chunk is base64-encoded binary data. I need to write some code in JS that will download this kind of stream like you are downloading a regular file in browser.
Supposing I’m already connected to my NativeMessaging host and am ready to receive data chunks, it should be something like this:
port.onMessage.addListener(function(msg) {
var chunk = msg.text // Base-64 encoded chunk
// Some code to decode base64 and download chunk stream
});
I have checked out Chrome’s downloads API but not sure if it can be somehow useful in my case.
[ad_2]