#Whats the best way to upload files to mongoDB

12 messages · Page 1 of 1 (latest)

plucky pewter
#

If you are developing an application with a frontend then don't save image or files to MongoDB directly, not a good idea. Use multer on nodejs, with multer you can save it to local machine like in public folder or any kind of cloud bucket as well, you need to have the file name which multer will provides you when you upload the file, just save the filename or path to database and on fetching data attach machine address with file name like, photoPath: http://ip_address/uploads/filename. And make sure enable public folder is served. If you don't wanna do that then save file in base64 format in MongoDB. but with this the problem will raise if these images has higher resolution then database size grows quickly.

polar bolt
#

Saving as base64 in Mongo is also a very bad idea. mongo has a file system called GridFS that you should use @normal scroll

#

If you want to store files in db

normal scroll
#

I heard about GridFs

plucky pewter
polar bolt
#

I also am looking into using Pechkin as a modern alternative but it's still a bit fresh

plucky pewter
normal scroll
polar bolt
normal scroll