BackendNode.jsCloudinaryAPIBackend

Building a Scalable File Upload API with Cloudinary and Node.js

Handle image and file uploads professionally with Multer and Cloudinary — including transformation, compression, and storage.

Abdur Razzak

Abdur Razzak

Full-Stack Web Developer

August 20, 2025 8 min read

Why Cloudinary?

Storing uploaded files on your own server creates maintenance headaches — disk space, backups, CDN delivery. Cloudinary is a managed media cloud that handles storage, transformation, and CDN delivery with a generous free tier.

Receiving Files with Multer

Multer is an Express middleware that parses multipart/form-data requests and makes file buffers or temporary files available on req.file. Use memoryStorage to keep files in memory and stream them directly to Cloudinary.

Uploading to Cloudinary

Use the Cloudinary Node.js SDK to upload from a buffer with upload_stream. Specify a folder, set quality auto and fetch_format auto to automatically serve the best format and quality for each browser.

Deleting Old Files

When a user replaces their profile photo, delete the old one from Cloudinary using its public_id. Always store the public_id in your database alongside the URL so you can clean up orphaned assets without manual intervention.

Share this article

All posts
#Node.js#Cloudinary#API#Backend
Abdur Razzak — Full Stack Web Developer

Full-Stack Expert

MERN · React · Next.js · WordPress