background
Home / Portfolio / Express Multer Cloudinary
PORTFOLIO

Express Multer Cloudinary

Express upload image to Cloudinary using Multer packages.

#ExpressJS  #Multer  #Cloudinary  

Express Multer Cloudinary

Express upload image to Cloudinary using Multer packages.

Live demo : Not available yet.

Source code : GitHub

Features

  • Upload image to Cloudinary cloud.
  • Get image URL from Cloudinary cloud.
  • Delete image.

Tech Stack

Prerequisites

Installation and Usage

Clone the repository

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

cd into the directory

1cd multer-cloudinary
bash

Install dependencies

1npm install
bash

copy .env.example to .env

1cp .env.example `.env`
bash

Configure environment variables in .env file

.env
1CLOUDINARY_CLOUD_NAME= 2CLOUDINARY_API_KEY= 3CLOUDINARY_API_SECRET=
dotenv
Login or register to Cloudinary to get your cloud name, api key, and api secret.

Create database

1sequelize db:create
bash

Run migration

1sequelize db:migrate
bash

Run the app

1npm run dev
bash

API Documentation

Get all images

Get all images from database.

Request :

  • Method : GET
  • Endpoint : api/gallery
  • Headers :
    • Content-Type : application/json
    • Accept : application/json

Save Image

Save image to Cloudinary cloud and save image URL to database.

Request :

  • Method : POST
  • Endpoint : api/gallery
  • Headers :
    • Content-Type : multipart/form-data
  • Body :
    • title : 'string',
    • slug : 'string',
    • photo : 'file' 'PNG, JPEG, JPG, GIF, SVG, and WEBP'

Find Image

Find image by slug.

Request :

  • Method : GET
  • Endpoint : api/gallery/:slug
  • Headers :
    • Content-Type : application/json
    • Accept : application/json
  • Params :
    • slug : 'string'

Delete Image

Delete image from Cloudinary cloud and database.

Request :

  • Method : DELETE
  • Endpoint : api/gallery/:slug
  • Headers :
    • Content-Type : application/json
    • Accept : application/json
  • Params :
    • slug : 'string'