where is fs.root (HTML5) in windows

泪湿孤枕 提交于 2019-12-25 05:38:34

问题


I can write and read files using html5 filesystem. The file is written successfully and then read successfully as well. But i don't know the actual physical path of that. fileEntry.fullPath gieves only \log.txt as path. Can anyone tell where this file is actuall stored in my PC?

If anyone want to check code, here it is:

window.webkitRequestFileSystem(window.TEMPORARY, 1024 * 1024, function(fs) {

  // fs.root is a DirectoryEntry object.
  fs.root.getFile('log.txt', {create: true}, function(fileEntry) {

fileEntry.createWriter(function(writer) {  // writer is a FileWriter object.
console.log(fileEntry);
    writer.onwrite = function(e) { console.log('on write');console.log(e); };
    writer.onerror = function(e) { console.log('on write error');console.log(e);  };

var blob = new Blob(['Hello World!'], {type: 'text/plain'});
    writer.write(blob);

}, opt_errorHandler);

}, opt_errorHandler);
});

回答1:


When writing data to the local system, web clients (browsers) do not locally store files according to their virtual file names in the script. As the MDN developer guide notes, "It does not necessarily have a relationship to the local file system outside the browser." (Introduction to the File System API)

Therefore, creating a file named "log.txt" in the API does not cause the client to store a real file called "log.txt" on your PC. Google Chrome, for example, will only store a numerically named file (e.g., "00004") in a directory dedicated to sandboxed storage on the client device. The File System API cannot be used to write to the local file system in any way intended for external/outside access to the sandboxed storage area. Also note the to comply with the API spec, client may restrict the types of files that can be stored, such as prohibiting storage of executable code.



来源:https://stackoverflow.com/questions/18481995/where-is-fs-root-html5-in-windows

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!