Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chrome's native messaging send/receive binary data

I am working on a Chrome extension that communicates with an external executable through Chrome messaging protocol. The external application either accepts absolute path of a media file or gets its binary content from stdout.

Since only the extension side has access to the actual file (from drag and drop operation) and there is no way to send the absolute path to the external application, I figured I would read the binary input file through FileReader and send the binary to the executable. Though there doesn't seem to be a good way to send and receive binary string (or typed array) to/from an external executable.

I wish there was a way to just send the pointer of where the typed array is located.

Any idea how a large binary string can be sent and received from an external executable through the native messaging protocol.

https://developer.chrome.com/extensions/nativeMessaging

like image 520
Belaviyo Avatar asked Nov 09 '22 05:11

Belaviyo


1 Answers

There is no other way than using an own protocol to split the binary data and transport them base64 encoded via JSON from the browser extension to the native application which then collects the binary chunks together. Note that the JSON string can have a maximum of 4 GB (Chrome, Firefox) or 2 GB (MS Edge, as it uses 16 bit characters internally) in total size which needs to be considered when creating the message chunks.

like image 138
dominik Avatar answered Jan 04 '23 01:01

dominik