Documentation

Direct browser uploads

Create a short-lived signed upload URL on your server, then PUT the file directly from the browser.

Search Docs

Assets

Direct browser uploads

Live

Create a short-lived signed upload URL on your server, then PUT the file directly from the browser.

Goal

Avoid routing large user files through your own application server.

Current status

Live

This area is documented as current, user-reliable behavior.

Workflow

  1. 1Your backend calls assets.signedUploadUrl with bucket, key, visibility, expiresIn, and maxBytes.
  2. 2Your frontend uploads the File to the returned URL with the returned HTTP method.
  3. 3StackShift validates the token, stores the file, and returns asset metadata.

Server creates the upload URL

Example

ts
const upload = await stackshift.assets.signedUploadUrl({
  bucket: 'avatars',
  key: 'users/user_123.png',
  visibility: 'public',
  expiresIn: '10m',
  maxBytes: 5_000_000,
})

Browser uploads the file

Example

ts
await fetch(upload.url, {
  method: upload.method,
  body: file,
  headers: { 'Content-Type': file.type },
})

Expected result

The browser uploads directly to StackShift Assets without receiving API credentials.