0

だから私はこれを理解しようとして立ち往生しています。

fileEntry.file(function(file){
  var reader = new FileReader();
  reader.onloadend = function (e) {
    var anchor = document.createElement("a");
    anchor.setAttribute('href', "data:text/tsv;charset=UTF-8," + encodeURIComponent(this.result));
    anchor.setAttribute("download", "log.tsv");
    anchor.innerHTML = "Download Log Now";
    document.body.appendChild(anchor);

    alert("Download by clicking the damn link at the bottom.");

    //delete the file?
  }

  reader.readAsText(file);
});

だから私の質問は、ファイルが読み取られた後にどのようにファイルを削除するのですか? fileEntry.remove(function(){console.log("File Removed.")});コメントの場所を試してみましたが、うまくいきません。

何か案は?

4

1 に答える 1

0

これがよりクリーンなpromise ベースのbro-fsを見ることができます:

fs.init()
  .then(() => fs.readFile('file.txt'))
  .then(content => console.log(content))
  .then(() => fs.unlink('file.txt'))
于 2016-10-24T20:03:16.317 に答える