Answer the question
In order to leave comments, you need to log in
Is it a good way to store files on a server?
Task: a user without registration can upload and download their files. In the future, he can register and get additional functionality.
File storage idea.
There is a storage class that can write, read and store an array of files by key (md5). Structure:
/user_files/ef/eff7d5dba32b4da32d9a67a519434d3f.zip
/user_files/d5/d58e3582afa99040e27b92b13c8f2280.zip
md5(user_id+file_name+...)
. The database stores user_id, original file name and key. /user-files/download/d58e3582afa99040e27b92b13c8f2280/ -> Мой документ.zip
Answer the question
In order to leave comments, you need to log in
And "Download (given via php)" can be replaced with download via X-Accel-Redirect if nginx is installed
The scheme is not bad, but it's better to use sha1_file() to detect the same files. Those. first generate a checksum, then search the database for a duplicate, if there is one, check if the files match (this may take time, the background processing should be thought out). If the files are the same, then there is no point in keeping copies. In this case, the scheme in the database becomes a little more complicated, but disk space is significantly saved due to deduplication.
Metadata for each user must be stored individually and the link should be unique for each user.
Quite a normal system
I do almost the same myself. Only files "faceless". Title and meta in the database.
It is given through php, the folders themselves are naturally closed.
Cons are standard.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question