Upload files directly to your storage buckets. Supports both backend uploads (using API keys) and secure frontend uploads (using scoped tokens).
Authenticate your requests using API keys or scoped tokens.
All requests to the Upload API require the Authorization header with a Bearer token.
Full access. Keep secret.
Scoped access. Safe for clients.
Use for frontend applications and client-side code. Tokens are scoped to a specific file path and expire automatically.
Use for backend servers and server-side scripts. Provides full access to upload to any path.
Complete examples for uploading from frontend or backend.
Choose your upload method. Each example clearly shows where the code runs.
Your backend creates a scoped token for a specific file path. Your API key stays secure on the server.
import { UploadClient } from 'mediasaur';const client = new UploadClient({ apiKey: 'sk_...' });const { token } = await client.createToken({ bucket: 'my-bucket', path: 'users/123/avatar.png', expiresIn: 3600 // 1 hour});// Send token to frontendToken sent to frontend
Your frontend uses the token to upload directly. No API key exposed in client code.
import { UploadClient } from 'mediasaur';const client = new UploadClient();const file = fileInput.files[0];const result = await client.upload({ file, token, // Token from backend path: 'users/123/avatar.png' // Must match token path});console.log('File uploaded:', result.url);Create a scoped upload token for frontend use.
https://upload.mediasaur.com/tokenGenerates a signed JWT token that allows a client to upload a single file to a specific path.
AuthorizationstringrequiredMust be a valid API Key (sk_...)
bucketstringrequiredThe target bucket name.
pathstringrequiredExact path where the file will be uploaded.
expires_innumberToken validity in seconds. Default: 3600
Upload a file to storage.
https://upload.mediasaur.com/Uploads a file using multipart/form-data. Supports both API Keys and Upload Tokens.
AuthorizationstringrequiredAPI Key (sk_...) or Upload Token (token_...)
fileFilerequiredThe binary file content.
pathstringrequiredDestination path. Must match token path if using token auth.
bucketstringRequired ONLY when using API Key auth.