How to send much binary data from JavaScript to C++

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

How to send much binary data from JavaScript to C++

Postby somebodyy » Wed Aug 19, 2015 10:59 am

Hello,

what is the recommended way to send much (multiple MB) of binary data from JavaScript to C++?

I thought of the filesystem api, but the resulting filenames etc. are obfuscated.

From the GeneralUsage i can see that I can send requests like this:

Code: Select all
var request_id = window.cefQuery({
    request: 'my_request',
    persistent: false,
    onSuccess: function(response) {},
    onFailure: function(error_code, error_message) {}
});


However, for all I found, the request can only be a String. Is it a good idea to base64 multiple mb data and sent it as request?
Because that sounds like abusing the query mechanism.

Cheers

Somebodyy
somebodyy
Newbie
 
Posts: 7
Joined: Wed Aug 19, 2015 10:51 am

Re: How to send much binary data from JavaScript to C++

Postby magreenblatt » Wed Aug 19, 2015 11:12 am

It's probably best to use the network stack. For example, send the data using XMLHttpRequest and handle it via a custom request handler. See the GeneralUsage wiki page for related documentation.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: How to send much binary data from JavaScript to C++

Postby somebodyy » Tue Aug 25, 2015 5:59 pm

Thanks, I didn't even think of this :) I will try to implement it like that
somebodyy
Newbie
 
Posts: 7
Joined: Wed Aug 19, 2015 10:51 am

Re: How to send much binary data from JavaScript to C++

Postby HarmlessDave » Tue Aug 25, 2015 7:04 pm

Just don't make the mistake I did :) :

If you're using POST for that XmlHttpRequest, the custom handler needs to be http / https: and a subdomain like myapp.myapp.com, NOT a custom prefix like mydata://domain/
HarmlessDave
Expert
 
Posts: 370
Joined: Fri Jul 11, 2014 2:02 pm

Re: How to send much binary data from JavaScript to C++

Postby somebodyy » Thu Aug 27, 2015 3:50 pm

Hah, thats exactly the same mistake I did. I think this should be made a little more visible in the General Usage document :D
somebodyy
Newbie
 
Posts: 7
Joined: Wed Aug 19, 2015 10:51 am

Re: How to send much binary data from JavaScript to C++

Postby magreenblatt » Thu Aug 27, 2015 4:33 pm

somebodyy wrote:Hah, thats exactly the same mistake I did. I think this should be made a little more visible in the General Usage document :D

Documentation updated.. hopefully the warning is visible enough now ;)
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm


Return to Support Forum

Who is online

Users browsing this forum: Google [Bot] and 115 guests