我试图从blob响应中保存fileSystem中的图像,但是文件对话框没有显示,这是我的脚本:
var xhr2 = new XMLHttpRequest();
xhr2.open("GET", "http://website.org?url=http://www.google.com");
xhr2.responseType = "blob";
xhr2.onreadystatechange = function() {
if (xhr2.readyState == 4) {
console.log(xhr2.response); //Blob {type: "text/xml", size: 17830, slice: function}
$('img')[0].src=window.URL.createObjectURL(xhr2.response); //response image is showing fine
console.log($('#mydiv').attr('id')+'.jpg'); //suggestedName is 'web:file.html.jpg'
chrome.fileSystem.chooseEntry({ type:'saveFile',suggestedName:$('#mydiv').text()+'.jpg',accepts:[{ extensions:['jpg'] }] },function(fileEntry){
//chooseEntry is not creating file dialog
console.log(fileEntry); //undefined
});
}
};
xhr2.send(null);Manifest.json
"permissions": [
"http://www.website.org",
"syncFileSystem",
{"fileSystem": ["write", "directory"]}
],发布于 2013-11-26 17:44:37
好吧,我解决了。显然,suggestedName值不能具有字符':‘
https://stackoverflow.com/questions/20208643
复制相似问题