Multiple file download not working after cefsharp upgrade
Closed this issue · 0 comments
Is there an existing issue for this?
- I have searched both open/closed issues, no issue already exists.
CefSharp Version
127.3.50
Operating System
Windows 10
Architecture
x64
.Net Version
4.6.2
Implementation
WinForms
Reproduction Steps
After upgrading CefSharp from 114.2.120 to 127.3.50 the multiple file download is not working
I am using the below angular code to download the xml file. Need to download 3 files.
this.serviceObj.saveTextAsFile(report1, report1);
this.serviceObj.saveTextAsFile(report2, report2);
this.serviceObj.saveTextAsFile(report3, report13);
saveTextAsFile(textToWrite: string, fileNameToSaveAs: string) {
var textFileAsBlob = new Blob([textToWrite], { type: 'text/xml' });
var downloadLink = document.createElement("a");
downloadLink.download = fileNameToSaveAs;
if ((window as any).webkitURL != null) {
// Chrome allows the link to be clicked
// without actually adding it to the DOM.
var textFile = (window as any).webkitURL.createObjectURL(textFileAsBlob);
downloadLink.href = textFile;
downloadLink.click();
// manually revoke the object URL to avoid memory leaks.
(window as any).webkitURL.revokeObjectURL(textFile);
downloadLink.remove();
}
}
Below is my custom Download handler code
public bool OnBeforeDownload(IWebBrowser chromiumWebBrowser, IBrowser browser, DownloadItem downloadItem, IBeforeDownloadCallback callback)
{
OnBeforeDownloadFired?.Invoke(this, downloadItem);
if (!callback.IsDisposed)
{
using (callback)
{
callback.Continue(downloadItem.SuggestedFileName, showDialog: true);
}
}
return true;
}
public void OnDownloadUpdated(IWebBrowser chromiumWebBrowser, IBrowser browser, DownloadItem downloadItem, IDownloadItemCallback callback)
{
OnDownloadUpdatedFired?.Invoke(this, downloadItem);
if (downloadItem.IsComplete || downloadItem.IsCancelled)
{
if (isFileToBeOpenedByDefaultApplication(downloadItem.MimeType, browser))
{
if (browser.IsPopup)
{
browser.CloseBrowser(false);
}
if (downloadItem.IsComplete)
{
try
{
var dg = new Action(() =>
{
MessageBox.Show(string.Format("{0} has been downloaded successfully to {1}", Path.GetFileName(downloadItem.FullPath),
Path.GetDirectoryName(downloadItem.FullPath)), "File Download");
});
System.Windows.Threading.Dispatcher.CurrentDispatcher.BeginInvoke(dg);
Process.Start(downloadItem.FullPath);
}
catch (Exception e)
{
Logger.LogException("Process.Start Exception", e);
}
}
}
else
{
if (downloadItem.IsComplete)
{
var dg = new Action(() =>
{
MessageBox.Show(string.Format("{0} has been downloaded successfully to {1}", Path.GetFileName(downloadItem.FullPath),
Path.GetDirectoryName(downloadItem.FullPath)), "File Download");
});
System.Windows.Threading.Dispatcher.CurrentDispatcher.BeginInvoke(dg);
}
}
}
}
But only one file is getting downloaded. after that the download itself is not working. Please provide a solution
Expected behavior
3 xml files need to be downloaded.
Actual behavior
Only one file downloaded
Regression?
worked on CefSharp 114.2.120
Known Workarounds
no work arounds found
Does this problem also occur in the CEF Sample Application
Yes using WinForms command line args
Other information
no log infomation