skip to Main Content

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


  1. Just Store Image and PDFs in Your Server And Simply Store The FilePath in MongoDb Against Users.

    Login or Signup to reply.
  2. 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

    {
    _id:1,
    image:['image1','image2','image3']
    }
    

    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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search