Object file storage system for Moodle
A remote object storage file system for Moodle. Intended to provide a plug-in that can be installed and configured to work with any supported remote object storage solution.
There are a number of different ways you can use this plugin. See Recommended use case settings for recommended settings for each one.
Disk can be expensive, so a simple use case is we simply want to move some of the largest and oldest files off local disk to somewhere cheaper. But we still want the convenience and performance of having the majority of files local, especially if you are hosting on-prem where the latency or bandwidth to the remote filesystem may not be great.
Many of our clients have multiple moodle instances, and there is much duplicated content across instances. By pointing multiple moodles at the same remote filesystem, and not allowing deletes, then large amounts of content can be de-duplicated.
Some of our clients' Moodles are truly massive. We also have multiple environments for various types of testing, and often have ad hoc environments created on demand. Not only do we not want to have to store duplicated files, but we also want refreshing data to new environments to be as fast as possible.
Using this plugin we can configure production to have full read write to the remote filesystem and store the vast bulk of content remotely. In this setup the latency and bandwidth isn't an issue as they are colocated. The local filedir on disk would only consist of small or fast churning files such as course backups. A refresh of the production data back to a staging environment can be much quicker now as we skip the sitedir clone completely and stage is simply configured with readonly access to the production filesystem. Any files it creates would only be written to its local filesystem which can then be discarded when next refreshed.
Often you want a sanitised version of the data for giving to developers or other 3rd parties to remove or obfuscate sensitive content. This plugin is designed to work in this scenario too where the 3rd party gets a 'cleaned' DB, and can still point to the production remote filesystem with readonly credentials. As they cannot query the filesystem directly and must know the content hash of any content in order to access a file, there is very low risk of them accessing sensitive content.
https://github.com/catalyst/moodle-local_datacleaner
By default, when files are stored in remote object storage Moodle still proxies every file download through the web server: the file is fetched from the object store to the Moodle server and then streamed to the user. This is simple to set up but has significant downsides at scale:
Enabling Pre-Signed (signed) URLs changes this behaviour. When a user requests a file, Moodle generates a short-lived, cryptographically signed URL pointing directly at the object store and redirects the user's browser to it. The file is then downloaded directly between the user and the object store, bypassing the Moodle web server entirely.
Benefits include:
The trade-off is that signed URLs expose a time-limited direct link to the object store. You control the exposure window via the Pre-Signed URL expiration time setting and can restrict which file types are eligible via the Pre-Signed URL whitelist, so sensitive file types can still be proxied through Moodle's access-control layer if required.
See Pre-Signed URLs Settings for configuration options.
This plugin is GDPR compliant if you enable the deletion of remote objects.
| Moodle version | Totara version | Branch | PHP | MySQL | PostgreSQL |
|---|---|---|---|---|---|
| Moodle 4.4+ | MOODLE_404_STABLE | 8.1+ | 8.0+ | 13+ | |
| Moodle 4.2+ | MOODLE_402_STABLE | 8.0+ | 8.0+ | 13+ | |
| Moodle 3.10 - 4.1 | MOODLE_310_STABLE | 7.2+ | 5.7+ | 12+ |
$CFG->alternative_file_system_class = '\tool_objectfs\s3_file_system';$CFG->alternative_file_system_class = '\tool_objectfs\azure_blob_storage_file_system';$CFG->alternative_file_system_class = '\tool_objectfs\digitalocean_file_system';$CFG->alternative_file_system_class = '\tool_objectfs\swift_file_system';Note: Not all object stores listed below are tested/in-use directly by Catalyst and some rely on community contributions. If you require commercial support/help please contact us privately for details on our rates.
Amazon S3 bucket setup
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": ["s3:ListBucket"],
"Resource": ["arn:aws:s3:::bucketname"]
},
{
"Effect": "Allow",
"Action": [
"s3:PutObject",
"s3:GetObject"
],
"Resource": ["arn:aws:s3:::bucketname/*"]
}
]
}S3 Object Ownership is an Amazon S3 bucket-level setting that you can use to control ownership of objects uploaded to your bucket and to disable or enable access control lists (ACLs). By default, Object Ownership is set to the Bucket owner enforced setting and all ACLs are disabled. When ACLs are disabled, the bucket owner owns all the objects in the bucket and manages access to data exclusively using access management policies.
To provide control over S3 Object Ownership when storing files in an S3 bucket, users can now select from various ACL options. Previously, the default ACL was set to private, which could lead to access control limitations in certain configurations. This setting allows users to better manage permissions by choosing the most appropriate ACL option for their needs.
The available ACL options are:
For more details on S3 Object Ownership and permissions, refer to:
No open issues yet, or sync has not completed.