> ## Documentation Index
> Fetch the complete documentation index at: https://docs.learnway.xyz/llms.txt
> Use this file to discover all available pages before exploring further.

# ImageKit Media Management

> Handling profile avatars, course cover assets, certificate templates, and media transformations via ImageKit.

# ImageKit Media Management

LearnWay uses **ImageKit** for cloud-based media storage, dynamic on-the-fly transformations, automatic WebP optimization, and fast global CDN distribution.

***

## 1. Uploading Images (Admin / User)

Endpoints accepting media (such as avatar uploads or course covers) support `multipart/form-data`:

```http theme={null}
POST /api/v2/user/profile-image
Authorization: Bearer <token>
Content-Type: multipart/form-data

file: [Binary Image Data]
```

### Server Upload Flow

1. The `FileInterceptor` validates image MIME type and maximum payload size (5 MB).
2. The `MediaModule` uploads the file directly to ImageKit into dedicated folder hierarchies:
   * `/avatars/`
   * `/courses/`
   * `/certificates/`
3. Returns `fileId`, `url`, and `thumbnailUrl`.

***

## 2. Dynamic Image Transformations

You can append ImageKit URL query transformations for responsive client performance:

```
https://ik.imagekit.io/learnway/courses/cover.png?tr=w-400,h-250,fo-auto,q-80
```
