Avinash Dubey
Avinash Dubey

Reputation: 128

Reading 1 GB file in 10 KB chunks and saving in different location

I want to read a 1 GB file in 10 KB chunk and move it to a different location (let say different folder for now) in Nodejs. I have read about various options in nodejs such as createReadStream, readFile. But Issue is, in my code I want to read file in 10 KB chunk only and pipe data somehow and save data.

Upvotes: 0

Views: 200

Answers (1)

loganfsmyth
loganfsmyth

Reputation: 161457

ReadStream and readFile read the file in chunks, but the size is not configurable. If this is critical for you, you will need to use the low-level file API methods like fs.open, fs.read, fs.write, and fs.close.

Upvotes: 1

Related Questions