Nathan,

Its not about how the bytes are written, its more about how they are read. 
I guess the BlockStream just writes them one block at a time, but the 
underlying fs.createreadstream will still read them at 40960 bytes a time.

 - Gill

On Thursday, 2 August 2012 18:52:34 UTC-7, Nathan Rajlich wrote:
>
> You may want to check out "block-stream" if you require buffers in 
> specific chunk sizes: https://npmjs.org/package/block-stream
>
> On Thu, Aug 2, 2012 at 4:29 PM, Ben Noordhuis <[email protected]> wrote:
>
>> On Thu, Aug 2, 2012 at 9:21 PM, Gill <[email protected]> wrote:
>> > I have a code where the NodeJS server reads a file and streams it to
>> > response, it looks like:
>> >
>> > var fStream = fs.createReadStream(filePath, {'bufferSize': 128 * 1024});
>> > fStream.pipe(response);
>> >
>> > The issue is, Node reads the file exactly 40960 bytes a time. However, 
>> my
>> > app would be much more efficient (due to reasons not applicable to this
>> > question), if it reads 131072 (128 * 1024) bytes at a time.
>> >
>> > Is there a way to force Node to read 128 * 1024 bytes at a time from the
>> > stream?
>> >
>> > Thanks in advance!
>>
>> No. bufferSize is a hint, not an imperative. It's up to the operating
>> system to honor it.
>>
>> --
>> 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 [email protected]
>> To unsubscribe from this group, send email to
>> [email protected]
>> For more options, visit this group at
>> http://groups.google.com/group/nodejs?hl=en?hl=en
>>
>
>

-- 
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 [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Reply via email to