What is the best way through which we can store pdf and images in mongoDB database.
I was creating a careers page, in which the user have to submit his image and the resume along with other necessary details. How can I store the pdf and the image as it doesn’t consume much storage and doesn’t affect the website’s performance. Is there any CDN or cloud service which I can use ?
2
Answers
Just Store Image and PDFs in Your Server And Simply Store The FilePath in MongoDb Against Users.
I think it’s a bad practice to store data like that.
You should keep refrence of that pdf or images with unique constraint.
For example lets assume you have 3 image with name image1,image2,image3.
Your document should look like
From above you can fetch those images if needed to display from particular document.
you can fetch from directory with simply the name present in document.
In conclusion
You should keep your DB as light as possible.