Reputation: 925
I know that I can use:
chrome.downloads.download({
url: “http://your.url/to/download”,
filename: “suggested/filename/with/relative.path” // Optional
});
to save some file to a user specified location. Is there any way to make that location be a part of the extensions folder?
A few possible use cases:
Upvotes: 1
Views: 2547
Reputation: 20438
You can use the sandboxed filesystem api: https://www.html5rocks.com/en/tutorials/file/filesystem/
First, add the "unlimitedStorage
" permission to the manifest.
Then, access the filesystem, write files, and access them via filesystem: urls
webkitRequestFileSystem(PERSISTENT, 1024, function(filesystem) {
filesystem.root.getFile("test", { create: true }, function(file) {
file.createWriter(function(writer) {
writer.addEventListener("write", function(event) {
location = file.toURL()
})
writer.addEventListener("error", console.error)
writer.write(new Blob([ "test" ]))
}, console.error)
}, console.error)
}, console.error)
Upvotes: 4