2

Is there any way to save a content like a string or an image to a file(like "C:\temp") in Chrome extension?
Does chrome or js provide any API to handle file system?

Leslie Wu
  • 760
  • 3
  • 13
  • 29

2 Answers2

2

There is a way to trigger a system file save dialogue via JS.

function exportToFile() {
    var myString = "Lorem ipsum.";

    window.open('data:text/csv;charset=utf-8,' + escape(myString));
}
exportToFile();

Another way is to use the new FILE API.

http://www.html5rocks.com/en/tutorials/file/filesystem/

Tom
  • 556
  • 1
  • 7
  • 16
  • BTW, if you want to download a lot of existing files, you might want to just generate a set of URLs and use a download manager to save them. – Tom May 19 '14 at 11:37
  • There is also `chrome.downloads` API. – Xan May 19 '14 at 11:40
0

No, there is no way for a chrome extension to manage the filesystem aside from using a custom NPAPI plugin con can get more info about using NPAPI plugin at http://developer.chrome.com/extensions/npapi.html

frisco
  • 1,897
  • 2
  • 21
  • 29