options.fd in fs.createReadStream

282 views
Skip to first unread message

NodeJazz

unread,
Feb 9, 2012, 12:07:19 PM2/9/12
to nod...@googlegroups.com
What is the use of the 'fd' property of the 'options' parameter of the method fs.createReadStream? Can it be used to create a stream from a fd that is already available (obtained via fs.open callback)? eg

            var options = {};
            options.fd = fd;
            var readStream = fs.createReadStream(null, options);

--

Isaac Schlueter

unread,
Feb 9, 2012, 3:37:24 PM2/9/12
to nod...@googlegroups.com
Yes, that is what it's for. I think you still might need to pass in a
path, but maybe that's been fixed.

It's very rare that you should need to do this. Most of the time, you
just open the file for the stream.

> --
> Job Board: http://jobs.nodejs.org/
> Posting guidelines:
> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> You received this message because you are subscribed to the Google
> Groups "nodejs" group.
> To post to this group, send email to nod...@googlegroups.com
> To unsubscribe from this group, send email to
> nodejs+un...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en

Ben Noordhuis

unread,
Feb 9, 2012, 3:45:36 PM2/9/12
to nod...@googlegroups.com

Yes. However, there is a bug in node < 0.7.3 where the stream won't
start until you call stream._read(). It's fixed in f64989e:

https://github.com/joyent/node/commit/f64989e

NodeJazz

unread,
Feb 9, 2012, 3:58:09 PM2/9/12
to nodejs
> Yes. However, there is a bug in node < 0.7.3 where the stream won't
> start until you call stream._read(). It's fixed in f64989e:
>

Thanks for the clarification. I think I just bumped into this bug.

--
Reply all
Reply to author
Forward
0 new messages