最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - HTML5 FileSystem API - Stack Overflow

programmeradmin5浏览0评论

I have created file 'log.txt' by fileSystem API

function initFS(grantedBytes) {
    window.requestFileSystem(window.PERSISTENT, grantedBytes, function (filesystem) {
        fs = filesystem;

        fs.root.getFile('log.txt', { create: true, exclusive: true }, function (fileEntry) {

            // fileEntry.isFile === true
            // fileEntry.name == 'log.txt'
            // fileEntry.fullPath == '/log.txt'
            console.log(fileEntry.fullPath);



        }, errorHandler);
    }, errorHandler);
}

initFS(1024*1024);

And do not fully understand its structure. Is There any way to explore this file for example from Windows Explorer and see it in file system?

I have created file 'log.txt' by fileSystem API

function initFS(grantedBytes) {
    window.requestFileSystem(window.PERSISTENT, grantedBytes, function (filesystem) {
        fs = filesystem;

        fs.root.getFile('log.txt', { create: true, exclusive: true }, function (fileEntry) {

            // fileEntry.isFile === true
            // fileEntry.name == 'log.txt'
            // fileEntry.fullPath == '/log.txt'
            console.log(fileEntry.fullPath);



        }, errorHandler);
    }, errorHandler);
}

initFS(1024*1024);

And do not fully understand its structure. Is There any way to explore this file for example from Windows Explorer and see it in file system?

Share Improve this question asked Oct 6, 2013 at 9:45 Taron MehrabyanTaron Mehrabyan 2,2293 gold badges21 silver badges27 bronze badges 5
  • 1 The HTML5 FileSystem is sandboxed: there's no easy way to access it from Windows. This is a security feature to prevent hostile code from attacking the host file system. – user1864610 Commented Oct 6, 2013 at 9:48
  • And i can't even set src of script tag to this file??? – Taron Mehrabyan Commented Oct 6, 2013 at 9:52
  • The answer is no, and for good reasons. A more full answer, with reasons, is explained in my answer here: stackoverflow./a/19281109/2567232 – Phil Nicholas Commented Oct 9, 2013 at 21:12
  • Forgot to add.... your question/topic was already addressed in the Wiki for this tag (see stackoverflow./tags/html5-filesystem/info) – Phil Nicholas Commented Oct 9, 2013 at 21:14
  • You can play with that demo and see how filesystem structure changes. – vitalets Commented Oct 24, 2016 at 19:47
Add a ment  | 

3 Answers 3

Reset to default 3

There is an even simpler way. On chrome, visit these urls.
For http, it's "filesystem:http://"+location.host+"/persistent/".
For https, it's "filesystem:https://"+location.host+"/persistent/".

Sort of, the File-system API doesn't encrypt the data being stored locally. It does however change the file naming conventions up. So you may have named it log.txt but if you poke around where the file-system API stores files, you'd probably find it under some arbitrary randomly generated file name like "00010" or in a random directory like "24/00123".

Anyway, you can open each file up in a text editor - if your file had text written to it you would be able to view it as such. Or if you wrote JSON to the file-system API it would be in human-readable string format when you opened in the text editor.

On Windows 7, with Chrome it's found here:

C:\Users\{user}\AppData\Local\Google\Chrome\User Data\Default\File System\

If you want to find out where it is stored via Chrome on other OS please see this post

Log files that an end-user or maintainer might want to see should be stored someplace in the normal file system. While the checked answer suggests how to find them when the HTML5 API is used, this location is subject to change and is troublesome to find.

A better solution is to have the user choose the directory for log files (and perhaps other files) when the app is installed, using chrome.fileSystem.chooseEntry, and then retain that entry and save it in local storage so it can be reused on subsequent launches.

发布评论

评论列表(0)

  1. 暂无评论