# FiveManage CDN Integration Setup

## Overview

Sistem sekarang menggunakan FiveManage CDN untuk menyimpan file image users, menghemat ruang server dan meningkatkan performa.

## Environment Configuration

Tambahkan ke `.env` file:

```bash
# FiveManage CDN Configuration
FIVEMANAGE_API_TOKEN=
```

## Features

### 1. **Automatic Upload to CDN**

- File image langsung diupload ke FiveManage CDN
- Storage lokal tidak digunakan, menghemat disk space
- URL file disimpan di database sebagai `photo_profile`& `signature`

### 2. **File Validation**

- **Format**: JPG, PNG, GIF, WebP,
- **Ukuran**: Maksimal 10MB
- **Client-side validation**: Feedback langsung sebelum upload
- **Server-side validation**: Double-check di Laravel

### 3. **User Experience**

- Preview thumbnail untuk gambar
- Modal popup untuk view ukuran penuh
- File size indicator
- Error handling yang informatif

### 4. **Security & Performance**

- API token tersimpan di environment variables
- File naming convention: `image_photo_profile/signature_{user_id}_{timestamp}.{extension}`
- Comprehensive logging untuk debugging
- Graceful fallback jika upload gagal

## API Response Example

```json
{
    "status": "ok",
    "data": {
        "id": "7Awk0oBAGbw3NUsHQWlk6",
        "url": "https://r2.fivemanage.com/g5ca8Lg0Gu8aQs0cJrPw6/P65yxalmHeVo.png"
    }
}
```

## Configuration Files

- `config/fivemanage.php` - Main configuration
- `app/Services/FiveManageUploadService.php` - Upload service
- Views updated for proper URL handling

## Testing

1. Upload new image file via profile form
2. Check database untuk URL FiveManage
3. Verify file accessible via CDN
4. Check Laravel logs untuk upload status

## Error Handling

- Upload failure: User mendapat error message, form data preserved
- File too large: Client-side prevention + server validation
- Invalid format: Laravel validation + user feedback
- Network issues: Comprehensive error logging
