Cloudinary Storage Provider
This provider adds Cloudinary SDK configuration, Zod-validated environment variables, and a Multer middleware that accepts in-memory uploads (images, video, PDF) with type and size limits.
Features
- Zod-validated
CLOUDINARY_*environment variables - Configured Cloudinary SDK (
v2) - Multer memory storage with allowlist MIME types and 5 MB max file size
- MVC and Feature architecture variants
Installation Guide
npx servercn-cli add pr cloudinary-storageFile Structure
MVC
-
src/configs/env.ts -
src/configs/cloudinary.ts -
src/middlewares/upload-file.ts
Feature
-
src/shared/configs/env.ts -
src/shared/configs/cloudinary.ts -
src/shared/middlewares/upload-file.ts
Environment Configuration
src/configs/env.ts
Cloudinary client
src/configs/cloudinary.ts
The template also includes a commented uploadToCloudinary / deleteFileFromCloudinary example in the same file—copy it into a service or util when you wire routes.
Upload middleware (Multer)
src/middlewares/upload-file.ts
Usage
Attach the middleware to a route, then pass req.file?.buffer to an upload helper that streams to Cloudinary (see the commented block in cloudinary.ts in the template).