I'm using the HTML5 FileSystem API in a Chrome Packaged App to write to a log file. I want the user to be able to download this file, so I tried something along the lines of:
fs.root.getFile('log.txt', {create: false}, function(fileEntry) {
var url = fileEntry.toURL();
// do something with the file url
});
This doesn't help though, because the URL is something like filesystem:chrome-extension://eekedjcagggbfigdmifkmhkjbhiklnpj/temporary/log.txt
and it's not possible to open it somewhere.
What technique would you recommend to make a FileSystem API file in a Packaged App downloadable?
Edit: After reading through Ben Well's answer below, I realized that I'll have to clarify even more what I want. It would seem especially nice to me if there would be a technique that doesn't imply loading the HTML5 Filesystem API file contents, building a blob from it and writing that to a user-chosen path with chrome.fileSystem API.
Have you tried using chrome.fileSystem.chooseEntry? This API lets your app save files to the user's hard disk, wherever they want, letting your program have a Save As kind of command. This is a bit different to a download link, but is also more in harmony with V2 apps being like native apps.
chrome.fileSystem pops up a dialog asking the user to choose a location for a file. If you use the options for saving files, this returns you a file entry that has permissions to write to the location chosen by the user. The user can also create new files when you use these options.
来源:https://stackoverflow.com/questions/16402696/replacement-for-fileentry-tourl-in-chrome-packaged-apps