Upload Single Image (Cloudinary)
Upload Single Image (Cloudinary)
# Upload Single Image (Cloudinary)
Uploads a single image to Cloudinary storage and returns its secure URL, public ID, dimensions, and metadata. Used by the driver and user mobile apps to upload avatar images and KYC verification documents before passing URLs to profile or document endpoints.
---
### Endpoint Overview
- **Method:** `POST`
- **Route:** `/api/v1/upload/single`
- **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 |
| --- | --- | --- | --- | --- | --- |
| `image` | `File (Binary)` | **Yes** | — | Max: 10MB. <br>Allowed: `.jpg`, `.jpeg`, `.png`, `.webp`, `.gif`, `.avif`, `.heic`, `.heif` | The image file to upload |
| `folder` | `text` | No | `"uploads"` | e.g. `"drivers/kyc"`, `"drivers/avatars"` | Cloudinary destination folder |
---
### Response Body Schema (`201 Created`)
| Top-Level Key | Data Type | Description |
| --- | --- | --- |
| `success` | `boolean` | Indicates whether upload succeeded (`true`) |
| `image` | `object` | Uploaded image metadata and URLs |
#### `image` Object Fields
| Field | Data Type | Description |
| --- | --- | --- |
| `url` | `string` | Publicly accessible HTTPS Cloudinary URL |
| `publicId` | `string` | Unique Cloudinary public ID (used for deletions) |
| `width` | `integer` | Image width in pixels |
| `height` | `integer` | Image height in pixels |
| `format` | `string` | File format extension (e.g. `"jpg"`, `"png"`, `"webp"`) |
| `bytes` | `integer` | File size in bytes |
---
### Response Examples
#### 1\. `201 Created` — Image Uploaded Successfully
``` json
{
"success": true,
"image": {
"url": "https://res.cloudinary.com/goride/image/upload/v1758429900/drivers/kyc/drv_dl_sample.jpg",
"publicId": "drivers/kyc/drv_dl_sample",
"width": 1280,
"height": 720,
"format": "jpg",
"bytes": 245360
}
}
```
#### 2\. `400 Bad Request` — Missing File Field
When the form-data field `image` is not provided:
``` json
{
"success": false,
"error": "No file provided (field name: 'image')"
}
```
#### 3\. `400 Bad Request` — File Exceeds Size Limit (Max 10MB)
``` json
{
"success": false,
"error": "File too large."
}
```
#### 4\. `400 Bad Request` — Unsupported MIME Type
``` json
{
"success": false,
"error": "Unsupported file type \"application/pdf\". Allowed: image/jpeg, image/png, image/webp, image/gif, image/avif, image/heic, image/heif"
}
```
#### 5\. `502 Bad Gateway` — Cloudinary Upload Failure
``` json
{
"success": false,
"error": "Cloudinary connection timed out or rejected file"
}
```
---
### Status Codes Reference
| HTTP Status Code | Condition |
| --- | --- |
| **`201 Created`** | File uploaded and stored on Cloudinary; image details returned. |
| **`400 Bad Request`** | Missing file, file size exceeded 10MB, or unsupported file extension. |
| **`502 Bad Gateway`** | Third-party Cloudinary API error or failure. |
Authentication
AuthorizationBearer
Bearer authentication of the form Bearer <token>, where token is your auth token.