CEF Sharp Download image with session

2,109 views
Skip to first unread message

Mostafa Khaki

unread,
Feb 15, 2015, 10:22:27 AM2/15/15
to cefs...@googlegroups.com
I'm using CEFSharp in my WPF application.
I will connect to a website and give a session from the website, after that the website will show me a picture and after each page reload the picture will change.
the picture will not show if I don't have any sessions.
so I want to Download all the images, I mean that I want to reload the page every 1 minute and download the image.
the image url is some thing like: www.example.com/image.ashx, so it can return different images dynamically.
I found some example about how to download files with CEFSharp, but I can't use them because there wasn't complete code, there was just a part of code and I don't know how to use them.
so can you help to find a solution to download an image when my browser has a sessionID?

Mostafa Khaki

unread,
Feb 16, 2015, 4:43:34 AM2/16/15
to cefs...@googlegroups.com

I found some information about IDownloadHandler but I don't know how to use it?!
I have a Webview object, how can I send IDownloadHandler to my Webview browser Object.

Alex Maitland

unread,
Feb 16, 2015, 4:53:07 AM2/16/15
to cefs...@googlegroups.com
What version are you using? `WebView` was renamed to `ChromiumWebBrowser` a very long time ago. If you haven't already then please upgrade to version `37` as older version are no longer supported.

The `IDownloadHandler` interface has some info on how it should be used https://github.com/cefsharp/CefSharp/blob/master/CefSharp/IDownloadHandler.cs

A minimal implementation can be found here https://github.com/cefsharp/CefSharp/blob/master/CefSharp.Example/DownloadHandler.cs

The main github repository has example projects which can be used as reference.

For future posts please always include the version your using and any other background information that you think may be useful.

Mostafa Khaki

unread,
Feb 16, 2015, 8:12:28 AM2/16/15
to cefs...@googlegroups.com
I'm using version 1.25.5.0.
where can I find final version of cefsharp for WPF?
I'm new to CEFSharp, I looked at many examples but I can't understand because the they just some objects, I never find some example that can download any files..
I don't know how to use IDownloadHandler. all the examples in Github are just a class or an Object from IDownlLoadHandler, so in my application how can I use this class? (I'm new in this field and I need more helps or references.. sorry if my question is not professional)
first of all please help me to find final version of CEFSharp for WPF.
thank you so much.

Jørn Hansen

unread,
Feb 16, 2015, 2:47:39 PM2/16/15
to cefs...@googlegroups.com
Hi & welcome to CefSharp,

Some starting points:
https://github.com/cefsharp/CefSharp/
The main GitHub project page. I guess if you enter "CefSharp" in most search engines it should come out as the first hit.

If you scroll past the files section on that page you should see the contents of the `README.md` file. Here's a direct link to the same:
https://github.com/cefsharp/CefSharp/blob/master/README.md

Also at the top of this Google Group there is a link to our FAQ. I recommend you start by reading those two pieces of information to get an introduction to CefSharp.

Finally with the scenario you describe (that for each download you will get a new image from the server) I'm not sure `IDownloadHandler` will be of any help to you. Please understand CefSharp is primarily an (embeddable) web browser targeted at being operated by a human being, not an automation tool or "web-scraper". It has certain interfaces exposed for light customization. One of these is `IDownloadHandler` which you can think of as a customization point for providing you own UI for when you as a user navigate to a content type which would normally trigger a file download dialog.

--
Best regards,
JornH

Alex Maitland

unread,
Feb 17, 2015, 3:38:45 AM2/17/15
to cefs...@googlegroups.com
Out of curiocity, were you using 1.25.5.0 historically, or did you just install that version recently? If recently what lead you to install that version?

Mostafa Khaki

unread,
Feb 17, 2015, 9:48:48 AM2/17/15
to cefs...@googlegroups.com

thank you so much for your helps..
Jorn you are right, IDownloadHandler isn't good for my problem.
now I think about another solution, I have a javascript file that helps me to download files, I can execute DownloadFile(URL) javascript function and it will download the file for me, but CEFSharp will ask me to save file, how can I froce CEFSharp to download the file in a default location.. (exactly like Google chrome)?
I don't want to see this dialog any more..

Mostafa Khaki

unread,
Feb 17, 2015, 9:49:55 AM2/17/15
to cefs...@googlegroups.com

Alex, I found this file from an OLD solution! one my friend give it to me.

Jørn Hansen

unread,
Feb 17, 2015, 6:10:26 PM2/17/15
to cefs...@googlegroups.com
I think I just answered a very similar question on StackOverflow about 1/2 an hour ago: http://stackoverflow.com/questions/28565319/force-cefsharp-to-download-without-showing-dialog

Mostafa Khaki

unread,
Feb 18, 2015, 2:38:42 AM2/18/15
to cefs...@googlegroups.com
Thank you Jorn, it is me, I asked this question at Stackoverflow too..
your answer is very good.. thank you again.

Jørn Hansen

unread,
Feb 18, 2015, 11:49:21 AM2/18/15
to cefs...@googlegroups.com
:-)

BTW I think SO is *very* well suited for that kind for common and well described/defined questions. Typically easier to find stuff there than buried somewhere inside a thread in this discussion group.
Reply all
Reply to author
Forward
0 new messages