在Chrome Packaged应用程序中无需提示即可保存 [英] Save without prompt in a Chrome Packaged App
问题描述
我已经开始在Chrome浏览器中查看Google Googles Packaged Apps, http://developer.chrome.com/apps这似乎是一项伟大的技术,但处于早期阶段。
我的问题是:是否可以在没有提示的情况下使用应用程序中的fileSystem API将文件保存到计算机?我想创建一个可以保存日志文件等的应用程序。 就像今天一样,如果不在应用程序沙箱外面提示我们,就无法访问文件系统。但它可能会在未来。但是,有一个名为Node-Webkit的新项目,与Chrome打包应用程序非常相似,在Chrome打包应用程序中,您可以使用HTML,js等在Chrome中开发应用程序浏览器中的nodejs。使用这个你可以访问文件系统和更多的东西。
在此处查看:
https ://github.com/rogerwang/node-webkit 和
https: //github.com/rogerwang/node-webkit/wiki
在Node-Webkit中加载和保存文件非常简单。它看起来像这样
var gui = require(nw.gui);
var fs = require(fs);
$ b $ //保存
fs.writeFile('message.txt','Hello Node',function(err){
if(err)throw err;
console.log('It'\\'s saved!');
});
$ b $ //加载
fs.readFile('message2.txt','utf8',函数(err,data){
if(err)throw err;
console.log(data);
});
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 question is: Is it's possible to save files to the computer using the fileSystem API from the app without a prompt? I want to make an app that can save log files etc.
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);
});
这篇关于在Chrome Packaged应用程序中无需提示即可保存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!