First let's declare the common issues we face while uploding a big image/file
- Where do images/files get physically stored?
- How do images/files get to the place they should be stored?
- How do we relate images/files to a particular entity?
Solution 1 - Database: 📌
So the first possible solution here would be take that image file and store it directly into database in our case it's mongoDB
Pros: ✅
- Easy to implement
- Easy to maintain
- Easy to scale
Cons: ❌
- Performance issues
- Not suitable for big files
- So expensive
Solution 2 - Server HD: 📌
The second possible solution here would be take that image file and store it directly into the server local Hard Drive. And this approach is what the most articles you will find on the internet.
Pros: ✅
- Not expensive
- Moust used approach
- Easy to maintain
- One to one maping (if we have only 1 server)
Cons: ❌
- Not scalable approach
- every HD related to only one server
- if we have multiple servers we need to have a HD for each server and this is not a good approach
Solution 3 - Cloud Storage: 📌
The third possible solution here would be take any file type and store it directly into the cloud storage like Amazon S3, Google Cloud Storage, Azure Blob Storage, etc.
Pros: ✅
- Massive collection of Hard Drives
- No maximum amount of storage
- Pay as you go (only pay for the data storage you using)
Conclusion: 📚
So in conclusion we can say that the best solution here would be take any file type and store it directly into the cloud storage like Amazon S3, Google Cloud Storage, Azure Blob Storage, etc. BUT this solution is not suitable for small and medium projects. So we have discussed the moust used approaches. Use the one that fits your project needs.
Leave a Reply