Versi sederhana untuk integrasi cepat.
file → binary (wajib){
"success": true,
"message": "File uploaded successfully",
"url": "https://raw.githubusercontent.com/XshopTopup/db.arsyilla/main/<nama-acak.ext>"
}
curl
curl -X POST https://url.arsyilla.my.id/upload \ -F "file=@/path/gambar.jpg"
Node.js (fetch)
import fs from "fs"
import FormData from "form-data"
import fetch from "node-fetch"
const fd = new FormData()
fd.append("file", fs.createReadStream("./gambar.jpg"))
const r = await fetch("https://url.arsyilla.my.id/upload", { method: "POST", body: fd })
console.log(await r.json())
Browser
const fd = new FormData()
fd.append("file", fileInput.files[0])
const res = await fetch("/upload", { method: "POST", body: fd })
const json = await res.json()
200 sukses400 tidak ada file500 gagal unggah