- Get Started
- Product
- Resources
- Tools & SDKs
- Framework
- Reference
- Get Started
- Product
- Resources
- Tools & SDKs
- Framework
- Reference
S3 File Module Provider
The S3 File Module Provider integrates Amazon S3 and services following a compatible API (such as MinIO or DigitalOcean Spaces) to store files uploaded to your Medusa application.
Prerequisites#
- AWS account.
- Create AWS user with AmazonS3FullAccess permissions.
- Create AWS user access key ID and secret access key.
- Create S3 bucket with the "Public Access setting" enabled:
- On your bucket's dashboard, click on the Permissions tab.
- Click on the Edit button of the Block public access (bucket settings) section.
- In the form that opens, don't toggle any checkboxes and click the "Save changes" button.
- Confirm saving the changes by entering
confirm
in the pop-up that shows. - Back on the Permissions page, scroll to the Object Ownership section and click the Edit button.
- In the form that opens:
- Choose the "ACLs enabled" card.
- Click on the "Save changes" button.
- Back on the Permissions page, scroll to the "Access Control List (ACL)" section and click on the Edit button.
- In the form that opens, enable the Read permission for "Everyone (public access)".
- Check the "I understand the effects of these changes on my objects and buckets." checkbox.
- Click on the "Save changes" button.
Register the S3 File Module#
Add the module into the providers
array of the File Module:
1import { Modules } from "@medusajs/framework/utils"2 3// ...4 5module.exports = {6 // ...7 modules: [8 // ...9 {10 resolve: "@medusajs/medusa/file",11 options: {12 providers: [13 {14 resolve: "@medusajs/medusa/file-s3",15 id: "s3",16 options: {17 file_url: process.env.S3_FILE_URL,18 access_key_id: process.env.S3_ACCESS_KEY_ID,19 secret_access_key: process.env.S3_SECRET_ACCESS_KEY,20 region: process.env.S3_REGION,21 bucket: process.env.S3_BUCKET,22 endpoint: process.env.S3_ENDPOINT,23 // other options...24 },25 },26 ],27 },28 },29 ]30}
S3 File Module Options#
Option | Description | Default |
---|---|---|
| The base URL to upload files to.
| - |
| The AWS or (S3 compatible) user's access key ID. | - |
| The AWS or (S3 compatible) user's secret access key. | - |
| The bucket's region code. For MinIO, use | - |
| The bucket's name. | - |
| The URL to the AWS S3 (or compatible S3 API) server.
| - |
| A string to prefix each uploaded file's name. | - |
| A string indicating how long objects remain in the AWS S3 (or compatible S3 API) cache. |
|
| A number indicating the expiry time of presigned URLs in seconds. |
|
| Any additional configurations to pass to the S3 client. Refer to this AWS API reference for a full list of accepted configuration. | - |
Additional Configuration for MinIO and Supabase#
If you're using MinIO or Supabase, set forcePathStyle
to true
in the additional_client_config
object.
For example: