Reputation: 6114
is it possible to download a file from a link like this "hxxp://abc.org/img.png" then save it in my local system. (The user should not select the directory or select it only once). Once the data is saved on client computer i can open that location and use any of the files ?
This is basically to run my application offline (chrome app). I have seen the fileSystem API of chrome app , it can open a file and modify it but did not see how to download a file and save it.
Please guide how to achieve this objective.
Upvotes: 0
Views: 352
Reputation: 834
I use fetch apt for this propouses.
var myHeaders = new Headers();
myHeaders.append('pragma', 'no-cache');
myHeaders.append('cache-control', 'no-cache');
var myInit = {
method: 'GET',
headers: myHeaders,
};
fetch(path, myInit)
.then(function (response) {
return response.blob();
})
.then(function (myBlob) {
File.system.root.getFile(filename, {create: true}, function (entry) {
entry.createWriter(function (writer) {
writer.write(myBlob);....
Upvotes: 1