diff --git a/README.md b/README.md index 7c63f01..2b5ec31 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ You can also clone this repository into your `node_modules` directory. var snapito = require('screenshot'); var screenshot = new snapito('yourapikey'); -screenshot.screenshot('http://www.google.com', 'google.png', {screen: 'desktop'}, function(file){ +screenshot.screenshot('http://www.google.com', 'google.png', {screen: 'desktop'}).on('close', function(file){ if (file) { console.log('The file ' + file + ' was written correctly'); } else { @@ -49,8 +49,8 @@ call to Snapito. Here is a list of them: var snapito = require('screenshot'); var screenshot = new snapito('yourapikey'); -// screenshot.screenshot(url, file, options, callback) -screenshot.screenshot('http://www.google.com', 'google.png', {screen: 'desktop'}, function(file){ +// screenshot.screenshot(url, file, options).on('event', callback) +screenshot.screenshot('http://www.google.com', 'google.png', {screen: 'desktop'}).on('close', function(file){ if (file) { console.log('The file ' + file + ' was written correctly'); } else { diff --git a/screenshot.js b/screenshot.js index 437488b..e8a3e9e 100644 --- a/screenshot.js +++ b/screenshot.js @@ -71,7 +71,9 @@ Screenshot.prototype.screenshot = function(url, file, options, callback) { options += params_string; // Send request - request(options).pipe(fs.createWriteStream(file)); + var fileStream = fs.createWriteStream(file); + request(options).pipe(fileStream); + return fileStream }; module.exports = Screenshot; \ No newline at end of file