Medusa File Google Cloud Storage Images
Google Cloud Platform (GCP) storage plugin for Medusa.js
Prerequisites
How to install
- Run the following command in the directory of your Medusa backend:
1npm install medusa-plugin-gcp
- Add following environment variables into your
:Copy to clipboard.env
123GCP_BUCKET=<YOUR_BUCKET_NAME>GCP_PRIVATE_KEY=<YOUR_SERVICE_ACCOUNT_PRIVATE_KEY>GCP_CLIENT_EMAIL=<YOUR_SERVICE_ACCOUNT_IAM_EMAIL>
- Open your
and add the below configuration:Copy to clipboardmedusa.config.js
1234567891011121314151617module.exports = {plugins: [...otherMedusaPlugins,{resolve: `medusa-plugin-gcp`,/** @type {import('medusa-plugin-gcp').PluginOptions} */options: {bucket: process.env.GCP_BUCKET,fileNaming: "original_random", // @default to original_random, options: original, random, original_randomcredentials: {private_key: process.env.GCP_PRIVATE_KEY,client_email: process.env.GCP_CLIENT_EMAIL,},},},],};
Test the plugin
- Run your Medusa backend:
1npm run dev
- Try to upload an image for a product using Medusa's admin interface. The image should appear into your storage bucket.
Additional resources
