Save without prompt in a Chrome Packaged App

前端 未结 3 1631
醉梦人生
醉梦人生 2021-01-19 10:23

I have started to look in to Googles Packaged Apps in Chrome, http://developer.chrome.com/apps which seems to be a great technology, but in an early stage.

My quest

3条回答
  •  天命终不由人
    2021-01-19 10:37

    I had some conversations with people involved in the packaged apps development and as it is today you cant have access to the file system without prompt our outside of an apps sandbox. But it might come in the future.

    But there is a new project called Node-Webkit that is very similar to Chrome packaged apps where you develop your app in Chrome with HTML, js etc where you also can run nodejs in the browser. Using this you can access the file system and many more things.

    Check it out here: https://github.com/rogerwang/node-webkit and https://github.com/rogerwang/node-webkit/wiki

    Loading and saving files in Node-Webkit is very easy. It looks like this

    var gui = require("nw.gui");
    var fs = require("fs");
    
    //Save
    fs.writeFile('message.txt', 'Hello Node', function (err) {
        if (err) throw err;
        console.log('It\'s saved!');
    });
    
    //Load
    fs.readFile('message2.txt', 'utf8', function (err, data) {
        if (err) throw err;
        console.log(data);
    });
    

提交回复
热议问题