Upload Media to Your Cosmic JS Bucket Using Multer


This is a quick, fully-working example of how to process an uploaded image server-side using Multer.

Open a terminal and run the following commands:

mkdir test
cd test
npm i cosmicjs multer express
vim index.js
// Add the gist code below to index.js
node index.js

Then if you're using Postman. Set this request up to test:

POST http://localhost:5000/upload

Add form-data file to the request.

Let me know if you have any questions! DM me in Slack, or reach out on Twitter.

Photo by Daniel Leone on Unsplash.



Was this article helpful?

Thank you! Your input helps us improve our articles and resources. If you have any other questions or comments, please contact support.

You may also like


In this tutorial, I'm going to show you how to create a minimalistic but awesome single page app blog using Vue, Vuex, Vuetify, Cosmic JS and deploy it to Netlify.
All of your images you upload to Cosmic JS are already transformed to imgix URLs, a powerful real-time image processing and CDN delivery solution. Let's take these images to the next level by optimizing image formats, compressing, intelligently cropping, & more!
In this article I’m going demonstrate how to add new form submissions to Hubspot when you Publish Objects in your Cosmic JS Bucket.
With revision history, you no longer have to worry about editing mistakes. You now have the power to go back in time and revert to to prior versions.
Cosmic JS makes it easy to deploy your websites and applications to the web. You can deploy an app from any git repository to the Cosmic App Server from any Bucket. Cosmic JS uses Dokku (Docker + Heroku-like deployment) to deploy your app from any GitHub, BitBucket or any other public repo.
Todo List app built using Svelte that utilizes the power of Cosmic JS.