DEV Community

Grey_W I N D
Grey_W I N D

Posted on

Best way to store images on server

I am an amateur in node and currently working on a realistic e-commerce project with mern-stack for my portfolio. And I have a problem on how to store images on node-express server. I have searched the web and found out that multer is quite good but it saves on my computer, I want to know from y'all here what methods you use to store your images whenever you are making an ecommerce website for a client.

Thank you...

Top comments (5)

Collapse
 
mashebang profile image
mashebang!

It saves on your computer because the whole environment is your computer. if you install and run the application on a server, it will save it on the server local disk.

btw, you can convert your image file to a base64 string and store it using mongo as a simples string value. but it will be a veeeery large string.

Collapse
 
siddharthshyniben profile image
Siddharth

Just don't forget to compress it – lzw (sample) works great, but you could always put together a custom one (maybe based on the fact that base64 strings contain only a limited subset of characters)

Collapse
 
rusty_xx profile image
Grey_W I N D

I recently worked on a tutorial video from javascriptmastery. I saw how he stored image in base64 string. But what I am trying to do is build my back-end api. So those images can be hosted. For instance, making a get request to this route ...localhost:5000/api/v1/productid/imageName. Brings out that particular image for that product. Just something I've seen and wanted to try out

Collapse
 
timtwiest profile image
Tim • Edited

Hey! I would recommend S3 (aws.amazon.com/s3/) from AWS. It's a Cloud-based storage service. That is highly scalable and rather simple to implement. However, you do need some basic AWS experience. This can also be used with Multer and this extra Multer libary (npmjs.com/package/multer-s3)

Collapse
 
rusty_xx profile image
Grey_W I N D

Thank you so much. I just read a bit about s3 bucket list. And watching tuts on it tonight.