Upload one Base64 object
curl --request POST \
--url https://api.fivemesh.io/v1/objects/base64 \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"data": "<string>",
"filename": "<string>",
"contentType": "<string>",
"path": "<string>",
"metadata": {}
}
'import requests
url = "https://api.fivemesh.io/v1/objects/base64"
payload = {
"data": "<string>",
"filename": "<string>",
"contentType": "<string>",
"path": "<string>",
"metadata": {}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
data: '<string>',
filename: '<string>',
contentType: '<string>',
path: '<string>',
metadata: {}
})
};
fetch('https://api.fivemesh.io/v1/objects/base64', 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://api.fivemesh.io/v1/objects/base64",
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([
'data' => '<string>',
'filename' => '<string>',
'contentType' => '<string>',
'path' => '<string>',
'metadata' => [
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"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://api.fivemesh.io/v1/objects/base64"
payload := strings.NewReader("{\n \"data\": \"<string>\",\n \"filename\": \"<string>\",\n \"contentType\": \"<string>\",\n \"path\": \"<string>\",\n \"metadata\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <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://api.fivemesh.io/v1/objects/base64")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"data\": \"<string>\",\n \"filename\": \"<string>\",\n \"contentType\": \"<string>\",\n \"path\": \"<string>\",\n \"metadata\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.fivemesh.io/v1/objects/base64")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"data\": \"<string>\",\n \"filename\": \"<string>\",\n \"contentType\": \"<string>\",\n \"path\": \"<string>\",\n \"metadata\": {}\n}"
response = http.request(request)
puts response.read_bodyFiveMesh CDN
Upload one Base64 object
Upload a Base64-encoded CDN object with a JSON request.
POST
/
objects
/
base64
Upload one Base64 object
curl --request POST \
--url https://api.fivemesh.io/v1/objects/base64 \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"data": "<string>",
"filename": "<string>",
"contentType": "<string>",
"path": "<string>",
"metadata": {}
}
'import requests
url = "https://api.fivemesh.io/v1/objects/base64"
payload = {
"data": "<string>",
"filename": "<string>",
"contentType": "<string>",
"path": "<string>",
"metadata": {}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
data: '<string>',
filename: '<string>',
contentType: '<string>',
path: '<string>',
metadata: {}
})
};
fetch('https://api.fivemesh.io/v1/objects/base64', 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://api.fivemesh.io/v1/objects/base64",
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([
'data' => '<string>',
'filename' => '<string>',
'contentType' => '<string>',
'path' => '<string>',
'metadata' => [
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"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://api.fivemesh.io/v1/objects/base64"
payload := strings.NewReader("{\n \"data\": \"<string>\",\n \"filename\": \"<string>\",\n \"contentType\": \"<string>\",\n \"path\": \"<string>\",\n \"metadata\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <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://api.fivemesh.io/v1/objects/base64")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"data\": \"<string>\",\n \"filename\": \"<string>\",\n \"contentType\": \"<string>\",\n \"path\": \"<string>\",\n \"metadata\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.fivemesh.io/v1/objects/base64")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"data\": \"<string>\",\n \"filename\": \"<string>\",\n \"contentType\": \"<string>\",\n \"path\": \"<string>\",\n \"metadata\": {}\n}"
response = http.request(request)
puts response.read_bodyUpload one Base64-encoded file to FiveMesh CDN from a server-side integration.
Use this route when the source provides Base64 instead of file bytes, such as a
screenshot or mugshot capture.
Requires
cdn:write.
Keep the service key in a server-side script. Never send it to a FiveM client,
NUI bundle or browser.
Optional key used to replay the same successful upload response after a retry.
Raw standard Base64 or a Base64 data URL such as
data:image/png;base64,....
Padded and unpadded Base64 are accepted.Stored filename, including its extension.
File MIME type, such as
image/png. When omitted, the API uses the MIME type
from a data URL or falls back to application/octet-stream.Optional destination folder.
Optional metadata containing string, number or boolean values.
FiveM server example
This example sends raw PNG Base64 from a server-side Lua resource. The API key is read from the server ConVar and never sent to the player.local apiKey = GetConvar("FIVEMESH_API_KEY", "")
local payload = json.encode({
data = pngBase64,
filename = ("family-%d-member-%d.png"):format(familyId, memberId),
contentType = "image/png",
path = "family_mugshot",
metadata = {
familyId = tostring(familyId),
memberId = tostring(memberId),
source = GetCurrentResourceName(),
},
})
PerformHttpRequest(
"https://api.fivemesh.io/v1/objects/base64",
function(statusCode, responseBody, _, errorData)
local response = responseBody and json.decode(responseBody) or nil
if statusCode < 200 or statusCode >= 300 or not response then
print(("[FiveMesh] Upload failed (%s): %s"):format(
tostring(statusCode),
responseBody or errorData or "No response"
))
return
end
print(("[FiveMesh] Uploaded %s"):format(response.object.publicUrl))
end,
"POST",
payload,
{
["Authorization"] = "Bearer " .. apiKey,
["Content-Type"] = "application/json",
}
)
Base64 increases the request size. Prefer the multipart upload route when you
already have file bytes.
{
"success": true,
"object": {
"key": "family_mugshot/family-1-member-1.png",
"size": 12345,
"contentType": "image/png",
"etag": "3f2a...",
"publicUrl": "https://cdn.fivemesh.io/acme/family_mugshot/family-1-member-1.png",
"metadata": {
"familyId": "1",
"memberId": "1"
}
},
"requestId": "req_..."
}
Was this page helpful?
⌘I