简体   繁体   中英

Saving files locally for offline access in Chrome APP

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.

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);....

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM