Spanish Total.js
English
Documentation For AI agents
Contents

Upload Base64

POST /base64/{db}/: upload one file sent as a Base64 data URI in JSON.

.md GitHub
On this page
POST /base64/{db}/

Use this endpoint when your app has the file as a data URI, for example from a canvas or a clipboard paste. Send JSON with the token in the token query argument or the x-token header. The token needs Upload files and the storage {db}. A request can be up to 10 MB.

Body

FieldMeaning
name or filenameThe file name, with extension. Required.
file or dataThe file as a data URI: data:<content type>;base64,<data>. Required.
idYour own ID for the file (optional). Letters and digits only.

The query arguments hostname=1 and id work as in Upload files.

Example

curl -H "x-token: YOUR_TOKEN" -H "content-type: application/json" \
  -d '{"name":"forest.png","file":"data:image/png;base64,iVBORw0KGgo..."}' \
  "https://files.example.com/base64/photos/"
{"id":"JapO3c1i961f","name":"forest.png","size":1591,"type":"image/png","ext":"png","width":400,"height":300,"url":"/files/photos/JapO3c1i961f-ps.png"}

Errors

AnswerCause
[{"error":"Invalid file name"}]No name or filename.
[{"error":"Invalid file type"}]file is not a data URI with a content type.

Both come with status 400. See Errors and limits.

Made in Europe