npm.io
2.22.7 • Published 4d ago

@medusajs/file-local

Licence
MIT
Version
2.22.7
Deps
0
Size
26 kB
Vulns
0
Weekly
0
Stars
36.8K

Medusa logo

@medusajs/file-local

Documentation | Website

Building blocks for digital commerce

Medusa is released under the MIT license. PRs welcome! Discord Chat Follow @medusajs

Local File Module Provider for Medusa: stores uploaded files on the server's local filesystem and serves public files from the static directory. It's the default file provider for self-hosted applications and is meant for development; use a provider like @medusajs/file-s3 in production. It ships with @medusajs/medusa and is registered through the @medusajs/medusa/file-local path.

At a glance

Package @medusajs/file-local
Type Module Provider (File Module)
Provider ID localfs
Registered by default Yes, with id: "local" (not on Medusa Cloud, which uses file-s3)
Import from @medusajs/medusa/file-local

Installation

No installation needed. The provider is a dependency of @medusajs/medusa and is registered by default.

Usage

Register it yourself only to pass options. The File Module accepts exactly one provider.

import { defineConfig } from "@medusajs/framework/utils"

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

Private files aren't access-protected: their download URLs are plain file URLs, not signed URLs.

Configuration

Option Type Description Default
upload_dir string Directory where public files are stored. static in the current working directory
private_upload_dir string Directory where private files are stored. static in the current working directory
backend_url string Base URL used to build file URLs. http://localhost:9000/static

Resources

Keywords