I am using simple code below to retrieve a file stored in mongodb. The file is downloaded but not in PDF format. While writing the file, I have set the content_type
in grid-fs api
to application/pdf
and I see the file is there in Mongo. The file downloaded is just BigBangTheory
, not BigBangTheory.pdf
. Other formats e.g. text/html having the same issue.
res.set('Content-Type', 'application/pdf');
gfs.createReadStream({ filename: 'BigBangTheory.pdf' }).pipe(res);
Thanks! I appreciate your help!