Replacing fileEntry.toURL () in Chrome Packaged Packages

I use the HTML5 FileSystem API in the Chrome Packaged App to write to a log file. I want the user to be able to download this file, so I tried something line by line:

fs.root.getFile('log.txt', {create: false}, function(fileEntry) { var url = fileEntry.toURL(); // do something with the file url }); 

This does not help, because the URL is similar to filesystem:chrome-extension://eekedjcagggbfigdmifkmhkjbhiklnpj/temporary/log.txt and it cannot be opened anywhere.

What technique would you recommend making the FileSystem API file in a packaged application downloadable?

Editing: after reading in Ben Well's reply letter, I realized that I would need to clarify even more what I want. I would be especially pleased if there was a method that would not imply loading the contents of the HTML5 file system API file, creating a blob from it and writing it to the path chosen by the user using the chrome.fileSystem API .

+4
source share
1 answer

Have you tried using chrome.fileSystem.chooseEntry ? This API allows your application to save files to the user's hard drive, wherever they are, allowing your program to have a "Save As" command. This is slightly different from the download link, but also more consistent with the fact that V2 applications are native applications.

chrome.fileSystem displays a dialog box asking you to choose a location for the file. If you use the options to save files, this returns a file entry that has write permissions to the user-selected location. The user can also create new files using these options.

+4
source

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


All Articles