Im using Mongo database , PHP , Nodes.js and have a problem with saving files .
since : Files size may be more than 1PB (1000 TB) .
In my mind two ways to do it :
Witch is better ?
If you have other solution please let me know about that .
For large data storage, you usually don't want to store the giant data files (like images, music files, video files) itself in a database.
Instead, store the large files in the file system (probably across multiple drives/servers) and you can store a filename/volume reference in the database along with any other relevant meta data.
This will also allow you to stream these files directly from the file system to the user (upon browser request) more efficiently rather than having to translate them from database format into what you would send the user.
And, if you're going to have a ton of storage, you should probably design your system from the beginning to be able to easily use cloud storage services like AWS. I know some of the people behind a popular photo sharing service and they switched over to using AWS for image storage, saved a lot of money and got better performance and easier redundancy. If you aren't already planning to start with a hosting service, you should be thinking about how you would move at least part of your service to one over time.