Presigned URLs

Upload to any storage that issues signed URLs or POST policies.

presignedAdapter implements the generic presigned flow for any provider: Google Cloud Storage V4 signed URLs, Azure SAS URLs, Supabase signed upload URLs, S3 POST policies, or your own signing service.

  1. Select
  2. Validate
  3. getTarget()your backend signs
  4. PUT / POSTbrowser → storage
  5. Progress
  6. Done
  7. complete()optional
import { presignedAdapter } from "@uploadcn/core"

const adapter = presignedAdapter({
  async getTarget({ file, signal }) {
    const response = await fetch("/api/sign", {
      method: "POST",
      body: JSON.stringify({ name: file.name, type: file.type, size: file.size }),
      signal,
    })
    return response.json() // { url, method?, headers?, fields?, key?, publicUrl? }
  },
  async complete({ target, file }) {
    const response = await fetch("/api/files", {
      method: "POST",
      body: JSON.stringify({ key: target.key, name: file.name }),
    })
    return response.json()
  },
})

Target

Prop

Type

Without complete, the result is { key, url } (the URL without its signature query).

For S3 and R2 you don't need to write the signing route yourself, use s3Adapter with @uploadcn/server.

On this page