0
我使用webworker和同步方法在文件系統中創建文件。在Chrome中使用fileWriterSync寫入文件
一切正常,但當chrome更新到33版本時只能寫入一個文件。第二個文件顯示此錯誤:
ERROR: InvalidStateError: Failed to execute 'write' on 'FileWriterSync': An operation that depends on state cached in an interface object was made but the state had changed since it was read from disk.
Android中鉻(與版本32)都可以與桌面版Chrome的版本32是一切OK了。
是一個錯誤?
這個代碼是在bucle(同步文件系統!!)
fs.root.getDirectory('/'+dir+'/'+dir_image, {create: true});
fileEntry=fs.root.getFile('/'+dir+'/'+dir_image+'/f_'+filename, {create: true});
blob = new Blob([xhr2BLOB.response], {type: 'image/'+arr_image[2]});
writer=fileEntry.createWriter();
writer.write(blob); //here ERROR second time!!! only version 33!!!
解決方案:將xh2的響應類型更改爲'blob'a'arraybuffer'並創建如下所示的blob:'code'var arrayBuffer = xhr2BLOB.response; var blob = new Blob([new Uint8Array(arrayBuffer)],{type:'image /'+ arr_image [2]});'code' – user3346250