HTML5 FileSystem API

I created the file "log.txt" using the file system 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 I do not quite understand its structure. Is there any way to examine this file, for example, from Windows Explorer and see it in the file system?

+6
source share
3 answers

Sorting, the file system API does not encrypt data stored locally. However, it changes the file naming conventions. Thus, you can name it log.txt , but if you orient where the API file system file is stored, you will probably find it under a randomly generated file name, for example, “00010”, or in a random directory, for example “24 / 00123 ".

In any case, you can open each file in a text editor - if text was written in your file, you can view it as such. Or, if you wrote JSON in the file system API, it will be in a readable text format when you open it in a text editor.

On Windows 7 with Chrome, it is here:

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

If you want to know where it is stored through Chrome on another OS, see this post

+3
source

There is an even easier way. On chrome, visit these URLs. For http, this is "filesystem:http://"+location.host+"/persistent/" .
For https, this is "filesystem:https://"+location.host+"/persistent/" .

+3
source

Log files that may be required to be viewed by end users or maintainers must be stored somewhere on a regular file system. Although the verified answer tells you how to find them using the HTML5 API, this location can be changed and hard to find.

The best solution is for the user to select the directory for the log files (and possibly other files) when the application is installed using chrome.fileSystem.chooseEntry, and then save this entry and save it in local storage so that it can be reused on subsequent launches.

0
source

Source: https://habr.com/ru/post/955337/


All Articles