Qubaish Bhatti Qubaish Bhatti - 5 months ago 44
Node.js Question

saving image file in mongodb using node gm (graphic magic)

I am totally new in node and mongodb concepts. I am trying to save the image, file (meta data) saved successfully but its chunks are not saving.

I also read gm documentation but did not helped alot plus i am not facing any error. https://github.com/aheckmann/gm

here is my code

var writeStream = gfs.createWriteStream({
filename: file.name,
mode: 'w',
content_type: file.type,
metadata: {
uid: uid,
createdAt: Date.today().setTimeToNow()

and here is my file object which i am passing

file : { data: "blob:http://localhost:3000/2664926c-f5e3-4ed2-8c3e-0473fd759944", name: "photo.jpg", type: "image/jpeg"}

Help much appreciated :)


Finally I found the issue, we have to write the blob url after piping. Here is the change


Thanks :)