0

I want such functionality in my app:

User can attach an image from the local machine;
Each img will be stored in a DB;
Other users from other computers want to see the image too;

The Question is : How can I store an image in a DB, so that I avoid using paths to that img on the local machine, because if I do, it will be displayed on only the users that uploaded the img machine, others won't be able to see it? I'm using the MERN stack. Is there a way to store img's info in int format, and then rendering it int data to an image on frontend? MongoDB, ExpressJS, and React.

Muhammad Arslan
  • 380
  • 1
  • 4
  • 10
ReginaTheMean
  • 57
  • 1
  • 10
  • Just don't save images to a database. MongoDB documents are limited to 16 MB. This is not suitable for saving images (but it is possible). You can find a lot of questions about this on SO so you will definitely find answer also. For example you can start [here](https://stackoverflow.com/questions/4796914/store-images-in-a-mongodb-database/4800186). – Jax-p Jun 10 '21 at 11:33
  • 1
    Thank you! I've found a way in this post: https://stackoverflow.com/questions/62354249/best-way-to-store-images-in-mern-stack-web-application – ReginaTheMean Jun 10 '21 at 11:57
  • @LudmilaAblisimova: it is not mentioned in that post, but a common way to store images is AWS S3 (or S3-compatible services) – Sergio Tulentsev Jun 10 '21 at 12:46
  • @Sergio Tulentsev, thank you, I'll think of each and find the best option! – ReginaTheMean Jun 10 '21 at 13:34
  • @O. Jones yes, it does, I wasn't searching attentively enough before posting this question – ReginaTheMean Jun 10 '21 at 13:37
  • @LudmilaAblisimova: it was the same link you yourself posted :) The whole comment with the "Does this answer your question" part is auto-generated when one suggests closing a question as duplicate. – Sergio Tulentsev Jun 10 '21 at 13:38
  • I'm a newbie to SO, thank you, Sergio, I'll know that now – ReginaTheMean Jun 10 '21 at 13:40

0 Answers0