Upload Multiple Images (Batch Cloudinary Upload)

View as Markdown
# Upload Multiple Images (Batch Cloudinary Upload) Uploads multiple images in a single batch request to Cloudinary storage. Returns an array of uploaded image details with direct URLs and any failed uploads with error reasons. --- ### Endpoint Overview - **Method:** `POST` - **Route:** `/api/v1/upload/multiple` - **Authentication:** `None (Public)` - **Content-Type:** `multipart/form-data` --- ### Request Headers | Header | Type | Required | Description | | --- | --- | --- | --- | | `Content-Type` | `string` | **Yes** | Must be `multipart/form-data` | --- ### Request Body Schema (`multipart/form-data`) | Form Field | Data Type | Required | Default | Allowed Values / Constraints | Description | | --- | --- | --- | --- | --- | --- | | `images` | `Files (Binary Array)` | **Yes** | — | Max: 10 files, 10MB per file. <br>Allowed: `.jpg`, `.jpeg`, `.png`, `.webp`, `.gif`, `.avif`, `.heic`, `.heif` | Repeat `images` field for each file | | `folder` | `text` | No | `"uploads"` | e.g. `"vehicles"`, `"documents"` | Cloudinary destination folder | --- ### Response Body Schema (`201 Created` / `207 Multi-Status`) | Top-Level Key | Data Type | Description | | --- | --- | --- | | `success` | `boolean` | `true` if all files uploaded without error, `false` if any file failed | | `uploaded` | `array` | List of successfully uploaded images | | `failed` | `array` | List of files that failed to upload with error descriptions | #### `` `uploaded` Item Fields `` | Field | Data Type | Description | | --- | --- | --- | | `url` | `string` | Secure HTTPS Cloudinary URL | | `publicId` | `string` | Unique Cloudinary public ID | | `width` | `integer` | Width in pixels | | `height` | `integer` | Height in pixels | | `format` | `string` | File format (e.g. `"jpg"`, `"png"`) | | `bytes` | `integer` | File size in bytes | #### `` `failed` Item Fields `` | Field | Data Type | Description | | --- | --- | --- | | `originalName` | `string` | File name as submitted by client | | `error` | `string` | Failure error message | --- ### `Response Examples` #### ``1. `201 Created` — All Images Uploaded Successfully`` ``` json { "success": true, "uploaded": [ { "url": "https://res.cloudinary.com/goride/image/upload/v1758429900/vehicles/car_front.jpg", "publicId": "vehicles/car_front", "width": 1920, "height": 1080, "format": "jpg", "bytes": 450120 }, { "url": "https://res.cloudinary.com/goride/image/upload/v1758429901/vehicles/car_back.jpg", "publicId": "vehicles/car_back", "width": 1920, "height": 1080, "format": "jpg", "bytes": 420800 } ], "failed": [] } ``` #### ``2. `207 Multi-Status` — Partial Success (Some Succeeded, Some Failed)`` ``` json { "success": false, "uploaded": [ { "url": "https://res.cloudinary.com/goride/image/upload/v1758429900/vehicles/car_front.jpg", "publicId": "vehicles/car_front", "width": 1920, "height": 1080, "format": "jpg", "bytes": 450120 } ], "failed": [ { "originalName": "corrupted_file.png", "error": "Failed to upload file to Cloudinary" } ] } ``` #### ``3. `400 Bad Request` — Missing `images` Form Field`` ``` json { "success": false, "error": "No files provided (field name: 'images')" } ``` #### ``4. `400 Bad Request` — Exceeded Maximum Files Limit (Max 10)`` ``` json { "success": false, "error": "Too many files in one request." } ``` #### ``5. `400 Bad Request` — Unsupported File Format`` ``` json { "success": false, "error": "Unsupported file type \"application/pdf\". Allowed: image/jpeg, image/png, image/webp, image/gif, image/avif, image/heic, image/heif" } ``` #### ``6. `502 Bad Gateway` — All Uploads Failed`` ``` json { "success": false, "uploaded": [], "failed": [ { "originalName": "file1.jpg", "error": "Cloudinary connection timeout" } ] } ``` --- ### `Status Codes Reference` | HTTP Status Code | Condition | | --- | --- | | **`201 Created`** | All images were uploaded successfully to Cloudinary. | | **`207 Multi-Status`** | Partial batch success — some files uploaded, others failed. | | **`400 Bad Request`** | Missing `images` field, too many files (>10), file too large (>10MB), or invalid MIME type. | | **`502 Bad Gateway`** | All images in the batch failed to upload to Cloudinary. |

Authentication

AuthorizationBearer

Bearer authentication of the form Bearer <token>, where token is your auth token.