我有一個具有圖像的網址。我想用chrome api下載那個圖片。我正在開發一個Chrome應用程序,而不是擴展。 任何人都可以請告訴我我要去哪裏錯?如何使用chrome文件系統api從chrome應用中的url下載圖片?
我的代碼:
service('fileService', function($window){
this.saveUserInfo = function(theFilePath) {
// filepath is the url passed from controller{
// Get the directory entry stored (if any).
var fileUrl = "";
var config = {
type: 'saveFile',
suggestedName: 'TheBee.png',
accepts:[{extensions: ['png', 'jpg', 'jpeg']}]
};
chrome.fileSystem.chooseEntry(config, function(writableEntry) {
chrome.fileSystem.getWritableEntry(writableEntry, function(entry1) {
entry1.getFile(theFilePath, {create:true}, function(entry2) {
entry2.createWriter(function(writer) {
var blob = new Blob({type: 'image/png'});
writer.write(blob);
});
});
});
});
});
});
blob構造函數不應該帶2個參數嗎? '新的Blob([數據],{opts})' – Endless