3 ms·
I'm currently building (Rails 6) a multi-purpose solution that includes file management. I'm still conceptualizing the file handling side of things because I ha
by pelagicAustral 5y ago
I'm currently building (Rails 6) a multi-purpose solution that includes file management. I'm still conceptualizing the file handling side of things because I have a few bad experiences from the past that I dont want to repeat. What I've got so far:
I have a very web forum-like interface for the users to manage files. Threads contain and represent a single file or a collection of related files. The main 'post' holds the files and under it there's a simple versioning abstraction that chains previous versions of the files, each new version is much like a new comment on a forum thread. All meta-data is included in this threaded interface and makes files and file collections full-text searchable by description, tag or category.
Files are not to be stored on a database, they are stored on a file server. The action of attaching a file to one of these threads actually generates a unique hash for the file. On committing changes the file is then 'moved' (copied) to the file server and a record is created in the main application's database referencing the file location on the file server.
eg. User created thread "Important Pdf File" and uploads|attaches|links file "important.pdf". When the submission is ready the file will be moved to: fileserver://files/taxa/taxa/taxa/8jma6ge_important.pdf
Newer versions will just include a different hash.
The file id (hash) is then stored on the main application database (file_id: 8jma6ge)
If all hell breaks loose I still get to move things easily from one server to another, migrate to a different rdbms is unobtrusive.
Needless to say, users never get direct access to the files on the file server, they can only interact with the versions they've got on their own machines and with the versions exposed through the frontend.
-----
So far it appears this methodology works ok for an application a few hundred users. Storage is a concern, backups as well and one of the main problems is duplication of files on local machines.