Daffa File
API v1← Back to upload

Developer documentation

One endpoint.
Permanent files.

Upload files melalui multipart/form-data dan dapatkan URL permanent yang bisa langsung disimpan atau dibagikan. Support chunked upload untuk file besar hingga 2GB.

POST https://daffafile.ayiem.workers.dev/api/upload

Security

Authentication

Semua endpoint admin memerlukan header X-Admin-Key dengan API key yang valid. Public endpoints (upload, retrieve) tidak memerlukan authentication.

Header example
X-Admin-Key: your-admin-api-key-here
Simpan API key dengan selamat. Jangan dedahkan dalam client-side code atau public repositories.

Make a request

Upload via cURL

Kirim file menggunakan multipart/form-data. Nama field file yang digunakan adalah file. Max file size: 100MB.

1Pilih file

Gunakan file lokal dalam format yang didukung.

2Kirim request

POST sebagai multipart/form-data ke endpoint upload.

3Simpan URL

Ambil field url dari JSON response.

Terminal
curl -X POST https://daffafile.ayiem.workers.dev/api/upload \
  -F "file=@/path/to/image.png"

Response:

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

Large files

Chunked Upload

Untuk file lebih besar dari 100MB (max 2GB), gunakan chunked upload dengan 3 langkah:

1. Initialize Upload Session

POST /api/upload/chunked/init
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}'
filenamestringOriginal filename
contentTypestringMIME type (optional)
totalSizenumberTotal file size in bytes
totalChunksnumberNumber of 20MB chunks

2. Upload Chunks

POST /api/upload/chunked/:uploadId/:chunkIndex
curl -X POST https://daffafile.ayiem.workers.dev/api/upload/chunked/abc123xyz/0 \
  -F "chunk=@chunk0.bin"

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

3. Complete Upload

POST /api/upload/chunked/:uploadId/complete
curl -X POST https://daffafile.ayiem.workers.dev/api/upload/chunked/abc123xyz/complete
JSON response
{
  "success": true,
  "url": "https://daffafile.ayiem.workers.dev/api/aZ3kq9",
  "id": "aZ3kq9",
  "contentType": "video/mp4",
  "size": 524288000
}

Get files

Retrieve File

Dapatkan file dengan permanent URL. Redirect ke storage backend.

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

Response: File binary dengan headers yang sesuai.

Get File Info

GET /api/:fileId/info
curl https://daffafile.ayiem.workers.dev/api/aZ3kq9/info
JSON response
{
  "success": true,
  "id": "aZ3kq9",
  "contentType": "image/png",
  "size": 245678,
  "createdAt": "2026-08-21T20:00:00.000Z"
}

Admin only

Delete File

Soft delete file (memerlukan admin key).

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

File compatibility

Supported Formats

Daffa File menerima pelbagai format file:

PNG
JPG
GIF
WEBP
SVG
PDF
ZIP
MP3
MP4
DOC
ImagescategoryPNG, JPEG, GIF, WEBP, BMP, ICO, SVG
DocumentscategoryPDF, DOC, DOCX, XLS, XLSX, PPT, PPTX, RTF, TXT, MD
ArchivescategoryZIP, RAR, 7Z, GZIP, BZIP2
AudiocategoryMP3, OGG, WAV, FLAC
VideocategoryMP4, WEBM, AVI
FontscategoryTTF, OTF, WOFF, WOFF2
DatacategoryJSON, XML, HTML, CSS, JS, YAML, SQLite

Quotas

Rate Limits & Quotas

Max file size (regular)limit100 MB
Max file size (chunked)limit2 GB
Chunk sizelimit20 MB
Upload session TTLlimit1 hour
Cache TTLlimit30 days
File yang diupload bersifat permanent. Pastikan anda mempunyai hak untuk membagikan file tersebut.

Troubleshooting

Error Codes

400Bad RequestMissing file, invalid parameters
401UnauthorizedInvalid admin key
404Not FoundFile not found
413Too LargeFile too large
415UnsupportedUnsupported file type
500Server ErrorInternal server error
502Backend ErrorStorage backend error
Copied to clipboard