All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
Advice and best practice for a storage CMS with file manager.
Hi there
I am doing a personal project. I am trying to write some sort of file storage service (PHP, and mysql). It is internal, for limited use for fun, no real heavy use expected but I would still like to do it in the most robust way and follow the best practices.
Each user has a "drive".
DB table for files: uploaderid,filename, filesize ,crc32, path(sort of labels)
user can import files from other services remotely (like mega etc) or direct upload.
On upload file's CRC32 is computed, if a file with same crc32 exists on database, file is skipped and user is warned "duplicate exists". Otherwise, file is moved to user directory, and entry is added to the table.
the upload part and adding entries to this database is done.
On the server, I store files in a flat fashion, each user has a directory, file are thrown there (if they pass the crc32 duplicate check). The path in database is just for organization purpose. Some sort of labeling, for better visualizing on the front end.
For the visualization, I have managed to make use of an open source "tree" structure thing I found on github. I can easily adapt it to drag and drop (move files) from a folder to another or create new (empty) folders (technically new labels), etc.
The only part remaining is the file manager to see your own files.
I am facing few challenges with it that I am not sure what would be the optimal way to solve.
Right now I have the table for files and another for user accounts.
I can import the files from DB, loop (inefficiently) 2 times, once to initialize the tree (labels), and another to insert the files under the appropriate node. (the js tree thing I use needs you to define parent node for each entry, which is why all folder need to be done before adding their files)
If I create a new folder in the JS file viewer right, now unless a file is moved to it, the folder is not saved anywhere in the DB and is lost with next reload.
How should I organize things, should I create third table called folders/labels and put all directory names there and their parents?
Aside from this, any general advice on writing such tools?
The aim of the tool is for archive purpose, which is one of the reasons why I am writing it from the scratch. It is not a storage solution like nextcloud where each user has it is own space for himself, to upload and download his files. Here user only uploads, and browse directories that he is allowed to browse. But no download links are directly provided (via http at least).
Downloading files via http is easy to implement I guess (later if needed)? but for now we are leaving downloads to be done via internal ftp.
Comments
I think in addition to the files themselves you need to store the meta data about the tree structure of the directories.