admin管理员组文章数量:1414881
I am very new to node-webkit. I am using the following code to download a file. How would I go about running the file automatically when the file has finished?
var https = require('https');
var fs = require('fs');
var file = fs.createWriteStream("update_setup.exe");
var request = https.get(url + "/appdata/update_setup.exe", function (response) {
response.pipe(file);
});
I am very new to node-webkit. I am using the following code to download a file. How would I go about running the file automatically when the file has finished?
var https = require('https');
var fs = require('fs');
var file = fs.createWriteStream("update_setup.exe");
var request = https.get(url + "/appdata/update_setup.exe", function (response) {
response.pipe(file);
});
Share
Improve this question
edited Oct 10, 2013 at 4:45
hexacyanide
91.9k31 gold badges166 silver badges162 bronze badges
asked Oct 10, 2013 at 1:38
user2387226user2387226
1 Answer
Reset to default 6Just use the writable stream's close
event and spawn a child process. The event will fire once the response has pleted piping to the stream.
var https = require('https');
var fs = require('fs');
var exec = require('child_process').exec;
var file = fs.createWriteStream('update_setup.exe');
var request = https.get(path, function(res) {
res.pipe(file);
});
file.on('close', function() {
exec('update_setup.exe', function(err, stdout, stderr) {
// output from starting
});
});
本文标签: javascriptRun file after file download completeStack Overflow
版权声明:本文标题:javascript - Run file after file download complete - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745193492a2647026.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论