# File Upload Manual Testing Guide

## Prerequisites
1. Start the backend server: `npm run dev`
2. Have a valid JWT token (login first)
3. Have an image file ready for upload

## Test Upload Endpoint

### Using cURL

```bash
# Upload an image
curl -X POST http://localhost:3000/api/v1/upload/image \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -F "image=@/path/to/your/image.jpg"
```

### Expected Response

```json
{
  "success": true,
  "data": {
    "url": "/uploads/uuid-timestamp.jpg",
    "filename": "uuid-timestamp.jpg",
    "originalName": "image.jpg",
    "size": 12345
  }
}
```

### Test Cases

1. **Valid Image Upload**
   - Upload a JPEG, PNG, GIF, or WebP image
   - Should return 200 with image URL
   - Image should be compressed and converted to JPEG
   - Image should be resized to max 1200x1200 (maintaining aspect ratio)

2. **No Authentication**
   - Upload without Authorization header
   - Should return 401 Unauthorized

3. **No File**
   - POST without attaching a file
   - Should return 400 with error code 'NO_FILE'

4. **Invalid File Type**
   - Upload a non-image file (e.g., .txt, .pdf)
   - Should return 500 with error about invalid file type

5. **File Too Large**
   - Upload a file larger than 5MB
   - Should return 500 with error about file size

## Accessing Uploaded Files

Once uploaded, files can be accessed at:
```
http://localhost:3000/uploads/filename.jpg
```

## Implementation Details

### File Processing
- Images are automatically resized to fit within 1200x1200 pixels
- All images are converted to JPEG format with 85% quality
- Progressive JPEG encoding is used for better web performance
- Original files are deleted after processing

### File Naming
- Format: `{uuid}-{timestamp}.jpg`
- Example: `a1b2c3d4-e5f6-7890-abcd-ef1234567890-1638360000000.jpg`

### Storage Location
- Files are stored in the directory specified by `UPLOAD_PATH` environment variable
- Default: `./uploads`
- Directory is created automatically if it doesn't exist

### Security
- Authentication required for all uploads
- File type validation (images only)
- File size validation (max 5MB by default)
- Unique filenames prevent overwrites
