petehunt / react-howto

Your guide to the (sometimes overwhelming!) React ecosystem.
11.61k stars 772 forks source link

what method to use to upload image in a webpack+react+express+mongo project? #67

Open wwy2018 opened 7 years ago

wwy2018 commented 7 years ago

hi, i am building a webpack+react+express+mongo project. but i stuck with how to upload image into the project. i use mongo and mongoose for database and it works ok. but the image just couldn't be uploaded into my project. nice if you can help, thank you a lot!

ngoctranfire commented 7 years ago

Hey, so I believe that you should never store actual images in your database. What I would actually do is setup an image server, like an Amazon S3 cloud storage server, or like a Firebase Storage server through Google, in which you can upload images/videos/ or files to that server. Your database would then hold a reference to those images/videos/files as a a URL that can access those files with a special token or such.