2016-04-28 51 views
0

我試圖截斷FileEntry內容,但在嘗試執行任何與截斷有關的任何操作時(fileWriter.truncate(0)),在cordova.js(@ 989:9) - Error: exec proxy not found for :: File :: truncate中得到此錯誤,無論是或在seek之前。 FileEntry/FileWriter存在,我很好寫它。Cordova - 截斷文件代理未找到

我用科爾多瓦6.1.1


每請求時,一些代碼(這個存在的文件類中):

this.__write__ = function(fileEntry, dataObj) { 
    console.log("Attempting to write", dataObj); 

    fileEntry.createWriter(function (fileWriter) { 

     fileWriter.onwriteend = function() { 
      fileWriter.write(dataObj); 

      fileWriter.onwriteend = function() { 
       console.log("Successfully written to "+self.filename, dataObj); 

       if (params.onwrite) 
        params.onwrite.apply(self) 
      }; 

      fileWriter.onerror = function (e) { 
       throw new Error("Failed to write to "+self.filename, e.toString()); 
      }; 

      // If data object is not passed in, 
      // create a new Blob instead. 
      if (!dataObj) 
       dataObj = new Blob([''], { type: 'text/plain' }); 
     } 

     fileWriter.truncate(0); 
    }, function(){ 
     throw new Error("Failed to create write on "+self.filename); 
    }); 
} 

如果我添加truncate(0)fileWriter.write(dataObj);之前,我得到上述錯誤

+0

你能像樣本代碼一樣發佈更多細節嗎?你在android棉花糖上測試這個嗎? – Gandhi

+0

@Gandhi - 我正在使用'cordova run browser'在瀏覽器上測試它, – eithed

+0

你使用哪個版本的文件插件?正如我可以看到類似的問題已得到解決在文件插件版本4.1.0檢查此鏈接 - https://issues.apache.org/jira/browse/CB-10023 – Gandhi

回答

0

它與one類似,在文件插件版本4.1.0中得到修復的問題根據您的輸入,它可以在chrom如預期的那樣,但不是在Firefox中。可能是插件的問題。請按照您的建議提出錯誤,讓希望最好。乾杯。