Category

Storage

Version

1.0.5

Last updated

Jan 25, 2024, 08:48:50 AMa month ago

Local file storage

Store uploaded files to your Medusa backend locally.
Not suited for production environments

Features

  • Store product images locally

Prerequisites


How to Install

1. Run the following command in the directory of the Medusa backend:
npm install @sellerartifact-medusajs/file-local
2 . In
Copy to clipboard
medusa-config.js
add the following at the end of the
Copy to clipboard
plugins
array:
const plugins = [
// ...
{
resolve: `@sellerartifact-medusajs/file-local`,
options: {
upload_dir: "uploads/images", // optional
backend_url: "http://localhost:9000", // optional
storageType: "byDate", // optional, you can set 'flat' or 'byDate', default is 'flat'
},
},
]

storageType

you can set 'flat' or 'byDate'
  • flat: all files will be stored in the root of the bucket
  • byDate: files will be stored in a folder structure based on the date of upload, e.g.
    Copy to clipboard
    [upload_dir]/2024/01/24/Filename.jpg

Test the Plugin

1. Run the following command in the directory of the Medusa backend to run the backend:
npm run start
2. Upload an image for a product using the admin dashboard or using the Admin APIs.

Build your own plugins

Develop your own plugins with our API to speed up your processes.

Make your plugin available via npm for it to be shared in our Plugin Library with the broader Medusa community.