Mint a client-upload URL
curl --request POST \
--url https://your-site.com/api/storage-bunny/storage/upload \
--header 'Content-Type: application/json' \
--cookie payload-token= \
--data '
{
"collectionSlug": "<string>",
"filename": "<string>",
"filesize": 123,
"mimeType": "<string>"
}
'import requests
url = "https://your-site.com/api/storage-bunny/storage/upload"
payload = {
"collectionSlug": "<string>",
"filename": "<string>",
"filesize": 123,
"mimeType": "<string>"
}
headers = {
"cookie": "payload-token=",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {cookie: 'payload-token=', 'Content-Type': 'application/json'},
body: JSON.stringify({
collectionSlug: '<string>',
filename: '<string>',
filesize: 123,
mimeType: '<string>'
})
};
fetch('https://your-site.com/api/storage-bunny/storage/upload', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://your-site.com/api/storage-bunny/storage/upload",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'collectionSlug' => '<string>',
'filename' => '<string>',
'filesize' => 123,
'mimeType' => '<string>'
]),
CURLOPT_COOKIE => "payload-token=",
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://your-site.com/api/storage-bunny/storage/upload"
payload := strings.NewReader("{\n \"collectionSlug\": \"<string>\",\n \"filename\": \"<string>\",\n \"filesize\": 123,\n \"mimeType\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("cookie", "payload-token=")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://your-site.com/api/storage-bunny/storage/upload")
.header("cookie", "payload-token=")
.header("Content-Type", "application/json")
.body("{\n \"collectionSlug\": \"<string>\",\n \"filename\": \"<string>\",\n \"filesize\": 123,\n \"mimeType\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://your-site.com/api/storage-bunny/storage/upload")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["cookie"] = 'payload-token='
request["Content-Type"] = 'application/json'
request.body = "{\n \"collectionSlug\": \"<string>\",\n \"filename\": \"<string>\",\n \"filesize\": 123,\n \"mimeType\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"clientUploadContext": {
"prefix": "<string>",
"signedReceipt": "<string>"
},
"filename": "<string>",
"headers": {},
"method": "PUT",
"prefix": "<string>",
"url": "<string>"
}API reference
Mint a client-upload URL
Returns a short-lived signed (edge) or presigned (S3) URL so the browser can PUT file bytes straight to Bunny. Runs clientUploads.access, or requires collection create or update access when it is not set. Validates the file against upload.mimeTypes, upload.limits.fileSize and the restricted file types. The URL only accepts the declared size and MIME type and never overwrites an existing file. See Client uploads.
POST
/
api
/
storage-bunny
/
storage
/
upload
Mint a client-upload URL
curl --request POST \
--url https://your-site.com/api/storage-bunny/storage/upload \
--header 'Content-Type: application/json' \
--cookie payload-token= \
--data '
{
"collectionSlug": "<string>",
"filename": "<string>",
"filesize": 123,
"mimeType": "<string>"
}
'import requests
url = "https://your-site.com/api/storage-bunny/storage/upload"
payload = {
"collectionSlug": "<string>",
"filename": "<string>",
"filesize": 123,
"mimeType": "<string>"
}
headers = {
"cookie": "payload-token=",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {cookie: 'payload-token=', 'Content-Type': 'application/json'},
body: JSON.stringify({
collectionSlug: '<string>',
filename: '<string>',
filesize: 123,
mimeType: '<string>'
})
};
fetch('https://your-site.com/api/storage-bunny/storage/upload', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://your-site.com/api/storage-bunny/storage/upload",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'collectionSlug' => '<string>',
'filename' => '<string>',
'filesize' => 123,
'mimeType' => '<string>'
]),
CURLOPT_COOKIE => "payload-token=",
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://your-site.com/api/storage-bunny/storage/upload"
payload := strings.NewReader("{\n \"collectionSlug\": \"<string>\",\n \"filename\": \"<string>\",\n \"filesize\": 123,\n \"mimeType\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("cookie", "payload-token=")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://your-site.com/api/storage-bunny/storage/upload")
.header("cookie", "payload-token=")
.header("Content-Type", "application/json")
.body("{\n \"collectionSlug\": \"<string>\",\n \"filename\": \"<string>\",\n \"filesize\": 123,\n \"mimeType\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://your-site.com/api/storage-bunny/storage/upload")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["cookie"] = 'payload-token='
request["Content-Type"] = 'application/json'
request.body = "{\n \"collectionSlug\": \"<string>\",\n \"filename\": \"<string>\",\n \"filesize\": 123,\n \"mimeType\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"clientUploadContext": {
"prefix": "<string>",
"signedReceipt": "<string>"
},
"filename": "<string>",
"headers": {},
"method": "PUT",
"prefix": "<string>",
"url": "<string>"
}Authorizations
Body
application/json
Response
Signed upload URL and the resolved storage path.