Aplicativos Chrome: como salvar o conteúdo do blob no fileSystem em segundo plano?

No Chrome Apps, estou baixando um conteúdo de blob de um servidor usando JavaScript XHR (Angular $ http GET em particular, com o tipo de resposta 'blob')

Como devo salvar isso no sistema de arquivos do aplicativo chrome?

Atualmente usando um wrapper Angular na API do sistema de arquivos HTML5https://github.com/maciel310/angular-filesystem

Não quero mostrar ao usuário um pop-up (portanto, não posso usarchrome.fileSystem. chooseEntry )

ochrome.fileSystem.requestFileSystem A API é suportada apenas por aplicativos somente para quiosque. Portanto, eu estou usando a API FileSystem HTML5 em vez do Chrome.

Estou usando o código a seguir para fazer o XHR buscar o blob.

 $http({
          url: SERVER_URL+"/someVideo.mp4",
          method: "GET",
          responseType: "blob"
      }).then(function(response) {
          console.log(response);
          fileSystem.writeBlob(response.name, response).then(function() {
             console.log("file saved");
          }, function(err) {
              console.log(err);
          });
      }, function (response) {

      });

Este é o meu método writeBlob

writeBlob: function(fileName, blob, append) {
    append = (typeof append == 'undefined' ? false : append);

    var def = $q.defer();

    fsDefer.promise.then(function(fs) {

        fs.root.getFile(fileName, {create: true}, function(fileEntry) {

            fileEntry.createWriter(function(fileWriter) {
                if(append) {
                    fileWriter.seek(fileWriter.length);
                }

                var truncated = false;
                fileWriter.onwriteend = function(e) {
                    //truncate all data after current position
                    if (!truncated) {
                        truncated = true;
                        this.truncate(this.position);
                        return;
                    }
                    safeResolve(def, "");
                };

                fileWriter.onerror = function(e) {
                    safeReject(def, {text: 'Write failed', obj: e});
                };

                fileWriter.write(blob);

            }, function(e) {
                safeReject(def, {text: "Error creating file", obj: e});
            });

        }, function(e) {
            safeReject(def, {text: "Error getting file", obj: e});
        });

    }, function(err) {
        def.reject(err);
    });

    return def.promise;
},

Isso mostraSECURITY_ERR ComoIt was determined that certain files are unsafe for access within a Web application, or that too many calls are being made on file resources.

Qual a solução para isso?

Eu tentei usar--allow-file-access-from-files sinalizador ao iniciar o aplicativo. Isso não ajuda.

questionAnswers(2)

yourAnswerToTheQuestion