我正在尝试从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"]}
],

最佳答案

好的,我解决了。显然,suggestedName值不能包含字符“:”

关于javascript - 在XmlHttpRequest readyState 4内调用Chrome ChooseEntry,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/20208643/

10-09 18:59