简体   繁体   中英

Storing files in a webserver

I have a project using MEAN stack that uploads imagefiles to a server and the names of the images to db. Then the images are shown for users of the applications kinda like an image gallery.

I have been trying to figure out an effiecent way of storing the imagefiles. atm im storing them under the angular application in a folder /var/www/app/files

What are the usual ways of storing them in a cloud server like digital ocean, heroku and many others. Im a bit thrown off by the fact they offer many options for datastorage.

Lets say that hundres of thousands of images were uploaded by the application to the server. Saving all of them in inside your front end app in a subfolder might not be the best solution? or am i wrong with this.

I am very new to these webserver cloud services and how they actually operate.

Can someone clarify on what would be the optimal solution.

Thanks!

Saving all of them in inside your front end app in a subfolder might not be the best solution?

You're very right about this. Over time this will get cluttered, and unless you use some very convoluted logic, will slow down your server.

If you're using Angular and this is in the public folder sent to every user, this is even worse.

The best solution to this is using something like an AWS S3 Bucket (DigitalOcean has Block Storage and I believe Heroku has something a bit different). These services offer storage of files, and essentially act as logic-less servers. You can set some privacy policies and other settings, but there's no runtime like NodeJS that can do logic for you.

Your Node server (or any other server setup) interfaces with this storage server, and handles most of the fetching and storing of files. You can optionally limit these storage services so they can only communicate with your Node server, so any file traffic would be done through your Node server.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM