Reputation: 972
I am using CefSharp but the question applies also for CEF C++
I have javascript application that you can use to edit/transform images. After you are done you want to upload the image to CEF and save it in database/filesystem.
Javascript code uploads the file using FormData API as multipart/form-data. I have custom ResourceHandler which is handling the request and trying to read the post data.
However in
bool ProcessRequest(IRequest request, ICallback callback)
request.PostData.HasExcludedElements == true
and file binary data is missing. I found those posts
https://www.magpcss.org/ceforum/viewtopic.php?f=6&t=16625 https://magpcss.org/ceforum/viewtopic.php?f=6&t=14371
which describes the same problem. It seems this is not supported by CEF, however there is no workaround how to upload binary file.
How I am supposed to upload binary data (Blob) from Javascript to CEF?
Upvotes: 3
Views: 1354
Reputation: 1502
You can make an AJAX request to a fake URL like http://grab-this-image.com/grabme.htm?savas=filename
and intercept it in (C++) ClientHandler::OnBeforeResourceLoad()
Grab the data then return RV_CANCEL to cancel the navigation.
Upvotes: 1