Skip to content

coshopnz/medusa-plugin-file-cloud-storage

 
 

Repository files navigation

Google Cloud Storage

Store uploaded files to your Medusa backend on Google Cloud Storage.

codecov Renovate enabled Build

Features

  • Store product images on Google Cloud Storage.
  • Support for both private and public buckets.
  • Download/Delete product images on Google Cloud Storage.
  • Get URL product images on Google Cloud Storage.

Prerequisites


How to Install Plugin

1. Run the following command in the directory of the Medusa backend:

npm install medusa-plugin-file-cloud-storage

2. Set the following environment backend medusa variables in .env. If you are deploying to a GCP product that supports Application Default credentials, you can leave CLIENT_EMAIL and PRIVATE_KEY this omitted, and authentication will work automatically.:

CLIENT_EMAIL=<CLIENT_EMAIL>
PRIVATE_KEY=<PRIVATE_KEY>
BUCKET_NAME=<PRIVATE_KEY>

3. In medusa-config.js add the following at the end of the plugins array:

const plugins = [
  // ...
  {
    resolve: `medusa-plugin-file-cloud-storage`,
    options: {
        credentials : {
          client_email: process.env.CLIENT_EMAIL,
          private_key: process.env.PRIVATE_KEY
        },
        privateBucketName: process.env.GCP_STORAGE_PRIVATE_BUCKET_NAME,
        publicBucketName: process.env.GCP_STORAGE_PUBLIC_BUCKET_NAME,
        basePublicUrl: process.env.GCP_STORAGE_BASE_PUBLIC_URL,
    }, 
  },
]

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.


About

Medusa.js plugin to store files in Google Cloud Storage

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 99.0%
  • Other 1.0%