Page 1 of 1

HTTP Post with file

Posted: Sun Jun 03, 2018 10:55 am
by thefunkyjoint
Hi,

I know how to use TChromium to send a HTTP POST with text data by using something like the code below :

Code: Select all

Request := TCefRequestRef.New;
Request.Assign(l, 'POST', Data, Header);
But i need to send a file also (an JPG image for instance)... how can i do it ? Any examples ?

Thanks in advance !

Re: HTTP Post with file

Posted: Sun Jun 03, 2018 12:12 pm
by salvadordf
I've never done that but I guess it should be something similar to this :
https://stackoverflow.com/questions/129 ... h-chromium

That was a really old CEF1 example but most of the code can be reused in CEF3.

You will probably need to create a TCefPostDataElementOwn. Use a ICefPostDataElement interface variable to store the new TCefPostDataElementOwn and call ICefPostDataElement.SetToBytes or ICefPostDataElement.SetToFile with the binary data.

Then call TCefPostDataRef.AddElement to add the ICefPostDataElement.