Skip to content
This repository has been archived by the owner on Feb 27, 2024. It is now read-only.

Is there a way to initiate a download from code? #31

Open
DelphiGit opened this issue Jun 12, 2016 · 2 comments
Open

Is there a way to initiate a download from code? #31

DelphiGit opened this issue Jun 12, 2016 · 2 comments

Comments

@DelphiGit
Copy link

Hi,

I'm looking for a way to download an image from the web and save it locally. Something like this:
crm.Browser.Download('http://some.url.com/some/path/a_picture.jpg', 'c:\local\path\a_picture.jpg');

I've been trying to use the OnGetResourceHandler event, but I suppose I need to write my own ResourceHandler? Is that correct and how do I do that?

procedure TMainForm.crmGetResourceHandler(Sender: TObject;
const browser: ICefBrowser; const frame: ICefFrame;
const request: ICefRequest; out Result: ICefResourceHandler);
begin
if request.ResourceType = RT_IMAGE then
//Save image somehow
end;

This is just a simplified explanation. On the real website there might be 50, 80 or more images. The site requires that i log in first, so I can't just use "request.Url" with another http component, cause then I get a permission denied error.
Thanks in advance for any help and suggestions. :)

@felipedaragon
Copy link

felipedaragon commented Jun 12, 2016

Maybe this is what you are looking for: use OnGetResourceHandler like this and store and save from a stream to the disk ? :)

@DelphiGit
Copy link
Author

Thank you, I'll try to use that approach. Wish me luck! :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants