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.
- Select
- Validate
- getTarget()your backend signs
- PUT / POSTbrowser → storage
- Progress
- Done
- 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.