raprmdn / multer-cloudinary

Multer with upload to Cloudinary

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Express Multer Cloudinary

This is a simple example of how to use multer and cloudinary to upload images to the cloud.

Dependencies

Features

  • Upload images to the cloud
  • Get images from the cloud
  • Delete images from the cloud

Getting Started

Prerequisites

Installation

Clone this repository

git clone https://github.com/raprmdn/multer-cloudinary.git

Install the dependencies

npm install

Configure the environment variables.

Copy the .env.example file to .env and fill in the required values.

cp .env.example .env

Configure the cloudinary account.

Get CLOUDINARY_CLOUD_NAME, CLOUDINARY_API_KEY, and CLOUDINARY_API_SECRET from your cloudinary account here.

CLOUDINARY_CLOUD_NAME=your_cloud_name
CLOUDINARY_API_KEY=your_api_key
CLOUDINARY_API_SECRET=your_api_secret

Usage

Run the server

Note: Make sure you have installed global dependencies nodemon, sequelize.

# Create database
sequelize db:create

# Run migrations
sequelize db:migrate

# Run the application
# By default, the application will run on port 5000
npm run dev

API Documentation

GET api/gallery - Get all images from the cloud

POST api/gallery - Upload image to the cloud

Request Body: Content-Type: multipart/form-data
  • title string *required
  • slug string *required
  • photo file PNG, JPEG, JPG, GIF, SVG, and WEBP *required

GET api/gallery/:slug - Get image from the cloud

DELETE api/gallery/:slug - Delete image from the cloud

About

Multer with upload to Cloudinary


Languages

Language:JavaScript 99.0%Language:Shell 1.0%