DEV Community

loading...

MongoDB Pictures

yobretyo profile image Bret ・1 min read

How do you use pictures that are in MongoDB? I’m using a CMS “Strapi” and there’s pictures that are being uploaded, but I don’t know how to access them. I have collections “fish” and “coral”, but Strapi created a collection “upload_image” but, how do I access the pictures in MongoDB, to loop through?

Discussion (2)

pic
Editor guide
Collapse
eruizdechavez profile image
Erick Ruiz de Chavez

Storing images as blobs on a database (SQL or NoSQL) is usually a bad practice, and I really doubt Strapi is storing them in MongoDB. What happens most of the time is the image gets uploaded to some folder on your server and the path to such image is stored in the database (MongoDB in this case).

I would recomend looking first at Strapi's documentation if you have not already done so; also take a look at your server folders, there must be a folder where the images are saved (file names will probably be different, but the files should still be there as images).

Collapse
leandroandrade profile image
Leandro Andrade

In this case, I suggest to use a storage service like Amazon S3 to save your files and get the absolute path returned by S3 and then save them in your MongoDB.

Avoid to save binary files into database.