Upload gambar + API Key siap dipakai dari website eksternal
BLOB_READ_WRITE_TOKEN (otomatis dari Blob)API_KEYS = key1,key2,key3 (pisah koma)demo-key-change-me
curl -X POST https://YOUR-PROJECT.vercel.app/api/upload \ -H "X-API-Key: YOUR_API_KEY" \ -F "file=@/path/to/image.jpg"
const formData = new FormData();
formData.append('file', fileInput.files[0]);
const res = await fetch('https://YOUR-PROJECT.vercel.app/api/upload', {
method: 'POST',
headers: {
'X-API-Key': 'YOUR_API_KEY'
},
body: formData
});
const data = await res.json();
if (data.success) {
console.log('URL:', data.url);
// <img src={data.url} />
}
$ch = curl_init('https://YOUR-PROJECT.vercel.app/api/upload');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => ['X-API-Key: YOUR_API_KEY'],
CURLOPT_POSTFIELDS => [
'file' => new CURLFile('/path/to/image.jpg')
],
CURLOPT_RETURNTRANSFER => true
]);
$response = json_decode(curl_exec($ch), true);
echo $response['url'];
{
"success": true,
"id": "550e8400-e29b-41d4-a716-446655440000",
"url": "https://xxxxx.public.blob.vercel-storage.com/images/550e....jpg",
"size": 245760,
"contentType": "image/jpeg",
"filename": "foto.jpg"
}