@medusajs/file
Documentation | Website
Building blocks for digital commerce
File Module for Medusa: uploads, retrieves, and deletes files such as product images and import/export files. Storage is delegated to a File Module Provider, so you can swap local storage for S3 or another service without changing your code. It ships with @medusajs/medusa and is registered by default; resolve it in your code with container.resolve(Modules.FILE).
At a glance
| Package | @medusajs/file |
| Type | Infrastructure Module |
| Module key | Modules.FILE ("file") |
| Registered by default | Yes (with the Local provider; S3 provider on Medusa Cloud) |
Providers
The module must be configured with exactly one provider. Official providers:
| Package | Register with |
|---|---|
@medusajs/file-local |
@medusajs/medusa/file-local |
@medusajs/file-s3 |
@medusajs/medusa/file-s3 |
Installation
No installation needed. The module ships with @medusajs/medusa.
Usage
To change the provider, register the module in medusa-config.ts with the provider you want:
import { defineConfig } from "@medusajs/framework/utils"
module.exports = defineConfig({
// ...
modules: [
{
resolve: "@medusajs/medusa/file",
options: {
providers: [
{
resolve: "@medusajs/medusa/file-s3",
id: "s3",
options: {
// provider options
},
},
],
},
},
],
})
Configuration
| Option | Type | Description | Default |
|---|---|---|---|
providers |
{ resolve: string, id: string, options?: Record<string, unknown> }[] |
The file provider to use. Must contain exactly one provider. | Local provider (id: "local") |