Reputation: 1
I am working on a small project and I can upload data to a mongo database but so far I have been unable to save an image to the same database, a friend of mine advised me to send a reference to the database but at this stage I have not worked out how to do this, any assistance would be greatly appreciated.
Upvotes: 0
Views: 1223
Reputation: 399
You can use node-s3-uploader library from Turistforeningen or build something like that if you want to save on local disk. The work behind is get the image file which you received, transform it to multiple versions to optimize bandwidth, you keep a reference to original version on MongoDB or MySQL.
When client request an image, send them the original link, depend on which case they need, client will deduce original link to re-scale link.
Upvotes: 1
Reputation: 1997
Assets like image should not be saved to database system directly but to local disk of your server, and you just save the link of that image to the database.
The database system like mongodb or mysql should save things that will be queried, and that's why we use database system. Things like binary file or image should just save to the local disk, because the content of these file is unreadable, and also can not be queried. But the name, path or URL of these file can be queried, so we normally save these things to database system.
Upvotes: 0