To read file from aws s3 bucket using Node fs, we create a write stream.
For instance, we write
const s3 = new AWS.S3({ apiVersion: "2006-03-01" });
const params = { Bucket: "myBucket", Key: "myImageFile.jpg" };
const file = require("fs").createWriteStream("/path/to/file.jpg");
s3.getObject(params).createReadStream().pipe(file);
to call createWriteStreamn with the path to write the data to.
Then we call getObject to get the object by the bucket and key.
And we call createReadStream to read the file and call pipe to pipe the file to the file write stream to write it.