如何在GeckoFX中处理文件下载? [英] How do I handle file downloads in GeckoFX?

查看:76
本文介绍了如何在GeckoFX中处理文件下载?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用最新的GeckoFX 18(hindlemail的分支),并努力实现这种简单的方法:处理文件下载.

I am using the latest GeckoFX 18 (hindlemail's fork) and have tried hard to achieve this simple method : Handle file downloads.

我想知道GeckoWebBrowser中是否正在下载文件.没有文件下载事件,更糟糕的是:单击导致文件下载的链接不会触发/any/事件.它只是什么都不做.没有下载对话框,没有保存文件对话框,没有url,什么也没有.

I want to know if there is a file download happening in the GeckoWebBrowser. There is no file download event, and even worse : clicking a link that leads to a file download doesn't trigger /any/ event. It just doesn't do nothing. No download dialog, no save file dialog, no url, no nothing.

有没有办法处理文件下载?

Is there a way I can handle file downloads ?

推荐答案

使用后邮的geckofx分支,您将不得不处理LauncherDialog.Download事件.此事件具有多个参数,例如url,文件名等.

By using hindlemail's fork of geckofx you will have to handle LauncherDialog.Download event. This event has several parameters like url, filename, etc.

LauncherDialog.Download += LauncherDialog_Download;
////
void LauncherDialog_Download(object sender, LauncherDialogEvent e)
{
    string filename = e.Filename; //do something with filename
    string url = e.Url; //use webclient to download file from this url
}

即使这样做,您也将无法从Dropbox或Facebook之类的安全站点下载文件,但是它将下载某些内容,总比没有好.我对xul不太了解,因此我也很难下载文件.

Even with this you will not be able to download files from secure sites like dropbox or facebook but it will download something, better than nothing. I don't know much about xul so I also has a hard time downloading files.

我也尝试过:

void LauncherDialog_Download(object sender, LauncherDialogEvent e)
{
    WebBrowser ie = new WebBrowser();
    ie.Navigate(e.Url);
}

如果可以通过这种方式下载文件,它将显示Internet Explorer下载文件对话框.可能是请求标头之类的原因.我还使用Fiddler来查找Firefox发送到服务器的标头,但是我发现没有用.

It will show Internet Explorer download file dialog if file can be downloaded that way. Probably cause of request headers or something. I also used Fiddler to find out what headers Firefox sends to server but I found nothing useful.

这篇关于如何在GeckoFX中处理文件下载?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆