Storage Adapters allow you to save Directus files anywhere. The default storage adapter is the API server's filesystem, but you can also use the included adapter for AWS-S3 or create your own.
You can change your project's default storage adapter within the API configuration.
First you need to install the adapter (not installed by default, to keep dependencies small).
If are using the Directus Suite version, this version is missing the
composer.json file. Follow these steps before installing the AWS S3 storage to recreate
composer.json and update the composer autoloader. If there's already a
composer require league/flysystem-aws-s3-v3
Then simply set the following into your configuration file (by default
'storage' => [ 'adapter' => 's3', 'key' => 'your-aws-key', 'secret' => 'your-aws-secret', 'bucket' => 'your-aws-bucket-name', 'version' => 'latest', 'region' => 'us-east-1', 'options' => [ 'ACL' => 'public-read', 'Cache-Control' => 'max-age=604800' ], 'endpoint' => 's3-endpoint', 'root' => '/', 'thumb_root' => '/thumbnails', 'root_url' => 'http://<bucket>.s3-<region>.amazonaws.com', ]
rootoption indicates the root path of all uploads.
thumb_rootoption indicates the root path where all the thumbnails are going to be stored.
root_urlis the URL to access all the files stored in the bucket, such as your bucket url, or AWS CloudFront URL.
Read more about the ACL permissions here: https://docs.aws.amazon.com/AmazonS3/latest/dev/acl-overview.html#canned-acl.
If you want to set any new uploaded files to be publicly readable, you should set the
public-read, otherwise all these permission will follow you default S3 bucket permissions.
If you want to connect a custom AWS S3 endpoint (for example a minio server), you can (additionally to the the configuration above) add:
'storage' => [ 'adapter' => 's3', // ... 'endpoint' => 'http://minio.acme.com' ]