Download files to custom location

Post Reply
Posts: 23
Joined: Thu Jan 17, 2019 12:36 pm

Download files to custom location

Post by padamjain »


I am using CEF binaries 86.0.23 and FMXBrowser component.
one of the web page is trying to save csv file on the disk by opening a save as dialog box.

I have implemented below in my form :

procedure TMainForm.FMXChromium1BeforeDownload(Sender: TObject; const browser: ICefBrowser;
const downloadItem: ICefDownloadItem; const suggestedName: ustring;
const callback: ICefBeforeDownloadCallback);
S: string;
S := ExtractFilePath(ParamStr(0));
callback.cont(S + suggestedName, false);

But, It is always saving file in the exe path, its not showing that popup which asks user to select location to save file.

Any advises ?

User avatar
Posts: 2822
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain

Re: Download files to custom location

Post by salvadordf »


Read these pages for more information about the TChromium events related to the fli downloads :

You will have to execute the "callback" parameter found in the TChromium.OnBeforeDownload event asynchronously after you show your custom "Save as..." dialog.

Remember that the TChromium.OnBeforeDownload event is executed in a CEF thread and VCL is not thread safe. You will have to save all the parameters in fields or variables, then send a message to the form to show the "Save as..." diaglog in the main application thread.

Set all the saved interfaces to NIL after you use them or you will have shutdown issues.
Post Reply