Code Monkey home page Code Monkey logo

medusa-file-sanity's Introduction

medusa-file-sanity

Store uploaded files to your Medusa backend on Sanity.

Features

  • Store product images on Sanity CMS

Prerequisites


How to Install

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

yarn add medusa-file-sanity

2. Set the following environment variables in .env:

SANITY_PROJECT_ID=some-project-id
SANITY_DATASET=production
SANITY_TOKEN=some-token

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

const plugins = [
	// ...
	{
		resolve: `medusa-file-sanity`,
		options: {
			projectId: process.env.SANITY_PROJECT_ID,
			dataset: process.env.SANITY_DATASET,
			token: process.env.SANITY_TOKEN,
			apiVersion: '2021-10-21',
			useCdn: false, // `false` if you want to ensure fresh data
		},
	},
]

Test the Plugin

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

yarn start

2. Upload an image for a product using the admin dashboard or using the Admin APIs.

medusa-file-sanity's People

Contributors

abmenzel avatar

Stargazers

Michael Geiger avatar

Watchers

 avatar

medusa-file-sanity's Issues

Error: Image not found in Sanity

Hi! I'm using the plugin together with the "medusa-plugin-sanity". The medusa-plugin-sanity works fine - products are synced to Sanity - but I'm having issues with images - when I try to upload an image via the medusa admin, I get the following error:

Image not found in Sanity
error: An error occurred while processing product.updated: TypeError: Cannot read properties of undefined (reading '_id')

Might this have something to do with the version of Sanity? I'm using the latest v3.

I'm using the following medusa versions
"dependencies": {
"@medusajs/admin": "^6.0.1",
"@medusajs/cache-inmemory": "^1.8.7",
"@medusajs/cache-redis": "^1.8.7",
"@medusajs/event-bus-local": "^1.9.4",
"@medusajs/event-bus-redis": "^1.8.7",
"@medusajs/file-local": "^1.0.1",
"@medusajs/medusa": "^1.12.0",
"cors": "^2.8.5",
"dotenv": "^16.1.4",
"express": "^4.17.2",
"medusa-file-sanity": "^1.0.3",
"medusa-plugin-sanity": "^1.0.2",
},
"devDependencies": {
"@medusajs/medusa-cli": "^1.3.14",
},

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.