Broader Frontends
Author : Kazuhiro Hara
Article permalink

Solving an issue where images uploaded to S3 from Directus would not display

I got stuck while migrating articles with Directus. Images would not display and returned a 403 error. Static files such as images are not uploaded to the application itself; they are uploaded to S3.

Directus storage settings in Config provide many storage options, including local, s3, gcs, azure, cloudinary, and supabase.

I had configured it to upload images to an S3 bucket, and when I actually uploaded one, I could confirm from the AWS Management Console that it had been placed on S3. The S3 permissions also seemed fine. In that case, Directus-side access control might be the problem.

In the Directus admin screen, you can manage access control for each collection from Settings and Access Control, but there is also a menu called System Collections. By selecting it, you can manage access control for Directus's own collections.

The directus_files collection in there is the access control setting for file-related collections. By default, everything is denied. So changing this seemed likely to make the images display.

Directus file access permission settings

However, allowing all access seemed like it could be a security problem, so I allowed read access only for objects uploaded to S3. The rule was to allow Read only when storage is s3.

As a result, the images displayed. All's well that ends well.

AWSDirectus

Share