Created
March 4, 2016 16:51
-
-
Save stephaneerard/f4549da7fde609efdd36 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function _download() { | |
| return new Promise(function (resolve, reject) { | |
| debug("download", image.url); | |
| var tmpName = tmp.tmpNameSync(); | |
| var writable = fs.createWriteStream(tmpName); | |
| var streamSource = request(image.url); | |
| streamSource | |
| .on("response", function (res) { | |
| debug("download ended", res.statusCode); | |
| }) | |
| .on("end", function () { | |
| resolve(fs.createReadStream(tmpName)); | |
| }) | |
| .on("error", function (err) { | |
| debug("download error", err); | |
| }) | |
| .pipe(writable) | |
| ; | |
| }); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment