← Back to Daffa File

Daffa File API

Upload dan serve files dengan permanent URL. Simple, fast, dan developer-friendly.

Base URL: https://daffafile.ayiem.workers.dev/api

Authentication

Semua endpoint admin memerlukan header X-Admin-Key dengan API key yang valid.

Note: Public endpoints (upload, retrieve) tidak memerlukan authentication.

Endpoints

GET /api/health

Health check untuk monitoring.

curl https://daffafile.ayiem.workers.dev/api/health

Response:

{
  "success": true,
  "service": "daffa-file",
  "timestamp": "2026-08-21T20:00:00.000Z"
}

POST /api/upload

Upload file baru (max 100MB). Untuk file lebih besar, gunakan chunked upload.

ParameterTypeDescription
fileFileFile to upload (multipart/form-data)
curl -X POST https://daffafile.ayiem.workers.dev/api/upload \
  -F "file=@image.png"

Response:

{
  "success": true,
  "url": "https://daffafile.ayiem.workers.dev/api/aZ3kq9",
  "id": "aZ3kq9",
  "contentType": "image/png",
  "size": 245678
}

POST /api/upload/chunked/init

Initialize chunked upload session untuk file besar (>100MB, max 2GB).

ParameterTypeDescription
filenamestringOriginal filename
contentTypestringMIME type (optional)
totalSizenumberTotal file size in bytes
totalChunksnumberNumber of 20MB chunks
curl -X POST https://daffafile.ayiem.workers.dev/api/upload/chunked/init \
  -H "Content-Type: application/json" \
  -d '{"filename":"video.mp4","totalSize":524288000,"totalChunks":25}'

Response:

{
  "success": true,
  "uploadId": "abc123xyz",
  "id": "fileId123"
}

POST /api/upload/chunked/:uploadId/:chunkIndex

Upload chunk ke-n (0-indexed). Setiap chunk max 20MB.

ParameterTypeDescription
chunkFileChunk data (multipart/form-data)
curl -X POST https://daffafile.ayiem.workers.dev/api/upload/chunked/abc123xyz/0 \
  -F "chunk=@chunk0.bin"

POST /api/upload/chunked/:uploadId/complete

Complete chunked upload dan dapatkan permanent URL.

curl -X POST https://daffafile.ayiem.workers.dev/api/upload/chunked/abc123xyz/complete

Response:

{
  "success": true,
  "url": "https://daffafile.ayiem.workers.dev/api/aZ3kq9",
  "id": "aZ3kq9",
  "contentType": "video/mp4",
  "size": 524288000
}

GET /api/:fileId

Retrieve file dengan permanent URL. Redirect ke storage backend.

curl https://daffafile.ayiem.workers.dev/api/aZ3kq9

Response: File binary dengan headers yang sesuai.

GET /api/:fileId/info

Get file metadata (non-sensitive).

curl https://daffafile.ayiem.workers.dev/api/aZ3kq9/info

Response:

{
  "success": true,
  "id": "aZ3kq9",
  "contentType": "image/png",
  "size": 245678,
  "createdAt": "2026-08-21T20:00:00.000Z"
}

DELETE /api/admin/:fileId

Soft delete file (memerlukan admin key).

HeaderValue
X-Admin-KeyYour admin API key
curl -X DELETE https://daffafile.ayiem.workers.dev/api/admin/aZ3kq9 \
  -H "X-Admin-Key: your-admin-key"

Supported File Types

CategoryFormats
ImagesPNG, JPEG, GIF, WEBP, BMP, ICO, SVG
DocumentsPDF, DOC, DOCX, XLS, XLSX, PPT, PPTX, RTF, TXT, MD
ArchivesZIP, RAR, 7Z, GZIP, BZIP2
AudioMP3, OGG, WAV, FLAC
VideoMP4, WEBM, AVI
FontsTTF, OTF, WOFF, WOFF2
DataJSON, XML, HTML, CSS, JS, YAML, SQLite

Rate Limits & Quotas

LimitValue
Max file size (regular)100 MB
Max file size (chunked)2 GB
Chunk size20 MB
Upload session TTL1 hour
Cache TTL30 days
Warning: File yang diupload bersifat permanent. Pastikan anda mempunyai hak untuk membagikan file tersebut.

Error Codes

CodeDescription
400Bad request (missing file, invalid parameters)
401Unauthorized (invalid admin key)
404File not found
413File too large
415Unsupported file type
500Server error
502Storage backend error