Note: This plugin is not tested in any proper way, I wrote this for myself to store product images in between deployment, which it does. Please report any issues you encounter to help me (and the community) improve the plugin.
Note 2: This does NOT use GitHub as a cdn, files are served by the backend server.
Medusa file plugin to store files on GitHub, in a private repository. So that they are stored in between deployments.
- New files are uploaded to GitHub, and stored locally, where they will be served by the backend.
- On startup, the plugin will download all the images from GitHub and store them locally.
- Functional medusa server
- Fine grained GitHub access token with read/write permission to the repository where images will be stored (can be the same as your medusa project repository)
To configure your Medusa server, simply add the following plugin configuration to your medusa-config.js
file:
const plugins = [
...
{
resolve: medusa-file-github-private,
options: {
path: "images",
github_token: process.env.GITHUB_TOKEN,
repo: "my_medusa_project",
owner: "jasperaelvoet",
backend_url: process.env.BACKEND_URL,
},
},
...
]
path
: Folder where images will be stored in the GitHub repositorygithub_token
: Stored in a .env file as GITHUB_TOKEN=my_tokenrepo
: The repository where the images will be storedowner
: The owner of the repository (username)backend_url
: The url of your backend (without trailing slash - i.e.http://localhost:9000
orhttps://api.your-domain.com
).
yarn: yarn add medusa-file-github-private
npm: npm install medusa-file-github-private