Back to Medusa

{metadata.title}

www/apps/resources/app/infrastructure-modules/file/local/page.mdx

2.14.22.2 KB
Original Source

import { Table } from "docs-ui"

export const metadata = { title: Local File Module Provider, }

{metadata.title}

The Local File Module Provider stores files uploaded to your Medusa application in the /uploads directory.

<Note type="warning">
  • The Local File Module Provider is only for development purposes. Use the S3 File Module Provider in production instead.
  • The Local File Module Provider will only read files uploaded through Medusa. It will not read files uploaded manually to the static (or other configured) directory.
</Note>

Register the Local File Module

<Note>

The Local File Module Provider is registered by default in your application.

</Note>

Add the module into the providers array of the File Module:

<Note>

The File Module accepts one provider only.

</Note>
ts
import { Modules } from "@medusajs/framework/utils"

// ...

module.exports = {
  // ...
  modules: [
    {
      resolve: "@medusajs/medusa/file",
      options: {
        providers: [
          {
            resolve: "@medusajs/medusa/file-local",
            id: "local",
            options: {
              // provider options...
            },
          },
        ],
      },
    },
  ],
}

Local File Module Options

<Table> <Table.Header> <Table.Row> <Table.HeaderCell>Option</Table.HeaderCell> <Table.HeaderCell>Description</Table.HeaderCell> <Table.HeaderCell>Default</Table.HeaderCell> </Table.Row> </Table.Header> <Table.Body> <Table.Row> <Table.Cell>
  `upload_dir`
  
  </Table.Cell>
  <Table.Cell>
  
  The directory to upload files to. Medusa exposes the content of the `static` directory publicly. If you change the directory, it must be served and publicly accessible.
  
  </Table.Cell>
  <Table.Cell>
  
  `static`
  
  </Table.Cell>
</Table.Row>
<Table.Row>
  <Table.Cell>
  
  `backend_url`
  
  </Table.Cell>
  <Table.Cell>
  
  The URL that serves the files.
  
  </Table.Cell>
  <Table.Cell>
  
  `http://localhost:9000/static`
  
  </Table.Cell>
</Table.Row>

</Table.Body>

</Table>