【发布时间】:2016-09-06 09:32:37
【问题描述】:
我正在尝试使用浏览器从安全 URL (https) 保存下载的文件,但我在使用 Firefox 时遇到问题。
我使用 indexedDB 将文件存储在浏览器内存中,下载完成后,我尝试将文件保存在我的计算机中(我使用的是 Mac,但我认为这并不重要)
我有这段代码:
var fileRequest = fileHandle.getFile(); //from indexedDB
fileRequest.onsuccess = function(event){
{...}
var file = event.target.result;
var url = window.URL.createObjectURL(file, {type : fileMimeType, autoRevoke : true});
//I did this with form and not with a href because:
//https://bugzilla.mozilla.org/show_bug.cgi?id=979227
var form = document.createElement('form');
form.action = url;
document.body.appendChild(form);
form.submit();
浏览器要求将此文件保存在“下载”文件夹中,一切似乎都正常,但它总是提示此消息:
“在此页面上输入的信息将通过不安全的连接发送,并且可能被第三方读取。您确定要发送此信息吗?”
如果单击“确定”,文件保存良好,但此安全警告是用户最想在网页中阅读的,因此用户被吓跑了。
createObjectURL 创建的 url 也是一个安全的 url,因为就像: blob:https//blahblah
此警告不会出现在 Chrome 中(使用他自己的文件系统方法)。
我需要帮助:(
【问题讨论】:
-
同一版本的 chrome 有什么更新吗?
标签: javascript security firefox indexeddb