Can't download images #615

Closed
micahlmartin opened this Issue Aug 5, 2013 · 3 comments

Comments

Projects
None yet
4 participants
@micahlmartin

I'm trying to download an image the way it's described in the readme. Here is my code:

request("https://www.google.com/images/google_favicon_128.png").pipe(fs.createWriteStream('google_favicon_128.png'))

The problem is that the file is always 0 bytes. If I download with the standard https library and handle the data and end events it works just fine. Is there something I'm doing wrong?

@meteormatt

This comment has been minimized.

Show comment Hide comment
@meteormatt

meteormatt Jan 7, 2014

I have tested, It is OK on my side.

I have tested, It is OK on my side.

@nylen nylen closed this Aug 22, 2014

@mphasize

This comment has been minimized.

Show comment Hide comment
@mphasize

mphasize Sep 11, 2014

This happened to me when I process.exit()ed before the downloads where finished.

To listen for the event:

var r = request("https://www.google.com/images/google_favicon_128.png").pipe(fs.createWriteStream('google_favicon_128.png'))
r.on( "finish", function () { ... callback... } );

This happened to me when I process.exit()ed before the downloads where finished.

To listen for the event:

var r = request("https://www.google.com/images/google_favicon_128.png").pipe(fs.createWriteStream('google_favicon_128.png'))
r.on( "finish", function () { ... callback... } );
@nylen

This comment has been minimized.

Show comment Hide comment
@nylen

nylen Sep 11, 2014

Member

That works. Note that you're actually getting the finish event from the stream returned by fs.createWriteStream(), since pipe() returns the destination stream.

Member

nylen commented Sep 11, 2014

That works. Note that you're actually getting the finish event from the stream returned by fs.createWriteStream(), since pipe() returns the destination stream.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment