i new nodejs , have question regarding scenario of file download.
i understand node responds services using single threaded event loop. when request comes download , request pushed async call queue until result(file data) ready sent requesting user .
when result written user , being done through event loop cycle , or done differently outside event loop ?
will such kind of operation block server if precaution not taken in case of large file ? how handle scenario if can cause issue ?
the normal approach problem in node streams. streams unix pipes can send and/or receive data. using fs.createreadstream create stream reads file. calling pipe on stream can suck data file , push awaiting data sink; in example server request. then, without having worry, reader stream read data , raise events stream dutifully pipe writer stream.
here's stream tutorial covers in more detail.
Comments
Post a Comment