Skip to content


Subversion checkout URL

You can clone with
Download ZIP


request image + r.pipe(fs.createWriteStream(...)) = bad file :( #47

NHQ opened this Issue · 7 comments

2 participants


I'm trying to

var r = request({uri:'http://my-dev-ip/images/f68def8251d58fb9c9833168d8a7833a.gif', method:'GET'});

but the file that is being written is no good, for some reason. I have tried setting encoding for the response, with no luck. I also tried puling a profile pic from facebook, but with no better luck.

Sometimes the file seems to write completely blank. Yet when I request an html document, I have no problem writing that stream to a new file.

The simplicity of request makes this my failure all the more consternating. Help pls.


btw, you can shorten your code to


I was using request request@1.9.5 with node-v0.4.10-pre

I updated to request@1.9.9 and will try it out tomorrow morning first thing.



does this work now? i want to release 2.0 soon and i'm trying to get rid of all the pending bugs.


Sorry for the delay. (I thought I clicked to submit comment hours ago!)

Yes! Seems to be working fine, and with the shortened code as you provided. Thnx very much.

I have another question: What if I don't know the image file type I am requesting? That information will usually be in the response.headers. Is that object available to the writeStream?


you can still pass a callback to request that will be executed when the headers are received and you can check the content-type.

@mikeal mikeal closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.