# File Sharing Server - Dokumentasi

## Overview

Server HTTP untuk berbagi file (APK, mockup, dokumen) antar agent di lingkungan
Valet Parking. Berlaku di **match002** (192.168.88.250).

## Dua Server

| Server | Port | Fungsi | URL |
|--------|------|--------|-----|
| **Static Server** | 8082 | Download file | `http://192.168.88.250:8082/` |
| **Upload Server** | 8083 | Upload file | `http://192.168.88.250:8083/` |

## Upload File (untuk Agent Lain)

### Method 1: HTTP Upload (Rekomendasi)

```bash
# Upload APK
curl -F "target=apk" -F "file=@app-release.apk" http://192.168.88.250:8083/upload

# Upload mockup HTML
curl -F "target=mockup" -F "file=@mockup.html" http://192.168.88.250:8083/upload

# Upload dokumen
curl -F "target=docs" -F "file=@laporan.pdf" http://192.168.88.250:8083/upload
```

**Response sukses:**
```json
{
  "success": true,
  "filename": "app-release.apk",
  "size": 75474849,
  "target": "apk",
  "path": "/home/valet/apk/app-release.apk",
  "url": "http://192.168.88.250:8082/apk/app-release.apk"
}
```

### Method 2: SCP melalui WireGuard

```bash
# Agent lain bisa scp langsung ke match002 (butuh SSH key root)
scp file.apk root@192.168.88.250:/home/valet/apk/
# Atau via WireGuard
scp file.apk root@10.10.1.1:/home/valet/apk/

# Untuk mockup
scp mockup.html root@192.168.88.250:/home/valet/mockup/

# Untuk dokumen
scp laporan.pdf root@192.168.88.250:/home/valet/docs/
```

### Method 3: Via SSH langsung di match002

```bash
# Copy dari lokasi lain ke folder share
cp /path/to/file.apk /home/valet/apk/
cp /path/to/mockup.html /home/valet/mockup/
cp /path/to/doc.pdf /home/valet/docs/
```

## Struktur Folder

```
/home/valet/
├── index.html                   ← Halaman utama static server
├── upload_server.py             ← Upload server (port 8083)
├── apk/                         ← File APK Android
│   └── AParking-Valet-Operator-v1.1.0-release.apk
├── mockup/                      ← File HTML mockup UI
│   └── qris-payment.html
├── docs/                        ← Dokumen teknis & laporan
│   ├── MKP_SIT_UAT_RESULT_20260805.xlsx
│   └── SHARING_SERVER.md
└── sit_evidence_*/              ← Evidence SIT (folder temporal)
```

## Target Upload yang Tersedia

| Target | Folder | Untuk |
|--------|--------|-------|
| `apk` | `/home/valet/apk/` | File APK Android (.apk) |
| `mockup` | `/home/valet/mockup/` | Mockup HTML (.html) |
| `docs` | `/home/valet/docs/` | Dokumen (.pdf, .xlsx, .md) |

## Download (via Static Server)

Setelah upload, file bisa diakses langsung:

```
http://192.168.88.250:8082/apk/nama-file.apk
http://192.168.88.250:8082/mockup/nama-file.html
http://192.168.88.250:8082/docs/nama-file.pdf
```

## URL Langsung

| Resource | URL |
|----------|-----|
| Halaman utama download | `http://192.168.88.250:8082/` |
| Upload file | `http://192.168.88.250:8083/` |
| Upload API | `POST http://192.168.88.250:8083/upload` |
| Health check upload | `http://192.168.88.250:8083/health` |

## Manajemen Server

### Start ulang semua server
```bash
# Static server (port 8082)
pkill -f "http.server 8082"
cd /home/valet && nohup python3 -m http.server 8082 --directory /home/valet --bind 0.0.0.0 > /dev/null 2>&1 &

# Upload server (port 8083)
pkill -f "upload_server.py"
nohup python3 /home/valet/upload_server.py > /dev/null 2>&1 &
```

### Cek status
```bash
curl -s http://192.168.88.250:8083/health | python3 -m json.tool
curl -s -o /dev/null -w "%{http_code}" http://192.168.88.250:8082/
```

## Catatan

- Server listen di **0.0.0.0** → bisa diakses dari IP mana pun
- Upload server port 8083, static server port 8082
- Maks file upload: **200 MB**
- **Tidak ada autentikasi** — hanya untuk internal development
- File yang di-upload langsung bisa di-download tanpa perlu restart