Question about loading local resources in JCEF browser

Having problems with building or using the JCEF Java binding? Ask your questions here.

Question about loading local resources in JCEF browser

Postby ramyakrishnan » Thu Oct 08, 2015 8:59 am

Hi ,

I am trying to load a few image files from my local directory (file:///C:/) to my HTML which I have served by a server (localhost). But I get the error "Cannot load local resource " for this . I read a few articles online that pointed that this is not possible in Chrome (due to security issues) but there is a flag called --allow-file-access-from-files that can be turned on to let this happen.

Additionally, My HTML file also uses a json file to show some information using javascript. So When I tried loading the HTML from file:///C:/ instead of a server (localhost) to accomodate for the images, I get the "cross origin request" even though I put my JSON file locally too ( like file:///C:/ something.json). Is there any flags that can be turned on to remove this cross origin request error that cef browser is giving me ? something like --disable-web-security etc ? How can I turn it on in the code ? I could use any example on this if any.
Thank you .
ramyakrishnan
Mentor
 
Posts: 62
Joined: Wed Sep 16, 2015 12:21 pm

Re: Question about loading local resources in JCEF browser

Postby magreenblatt » Thu Oct 08, 2015 9:56 am

ramyakrishnan wrote:I am trying to load a few image files from my local directory (file:///C:/) to my HTML which I have served by a server (localhost).

There are no flags that let you access local files from a server. You can either serve the image files via a custom scheme handler (see examples in the detailed app) or via your server.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: Question about loading local resources in JCEF browser

Postby ramyakrishnan » Thu Oct 08, 2015 2:57 pm

Hi Marshall,

Thank you for the help. I tried a different approach and figured out a way to send BufferedImages to the browser using BufferedOutputStreams which solved my issue. I will also look into the idea of custom scheme handler as I did not understand it thoroughly when I went through it before.
ramyakrishnan
Mentor
 
Posts: 62
Joined: Wed Sep 16, 2015 12:21 pm


Return to JCEF Forum

Who is online

Users browsing this forum: No registered users and 131 guests