Files
outline/server/storage
Yinhao HuangandClaude Opus 4.8 6286d08171 feat: support presigned PUT uploads for S3-compatible storage (#12748)
* feat: support presigned PUT uploads for S3-compatible storage

Add `AWS_S3_UPLOAD_METHOD` config ("post" default / "put") so providers
that do not implement presigned POST (e.g. Cloudflare R2) can use
presigned PUT instead.

- BaseStorage.getPresignedPut() returns undefined by default; S3Storage
  overrides with PutObjectCommand + getSignedUrl.
- Content-Length is signed into the presigned PUT URL so S3 rejects
  uploads that do not match the declared size.
- API route and MCP tool branch on the config: only one upload method
  is returned per request.
- Frontend uses existing presignedPutUrl presence check — unchanged.
- When put is configured but unsupported (e.g. LocalStorage), a clear
  InvalidRequestError is returned.

Defaults to "post" — zero behavior change for existing deployments.

* refactor: return explicit upload mode instead of inferring from fields

Address review feedback from @tommoor: the client should not need to
infer the upload method from the presence of presigned-PUT-specific
fields. The API now returns an explicit `mode` ("put" | "post"), and the
PUT branch uses generic `url` / `headers` fields so the client has no
special knowledge of "presigned puts".

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* refactor: use this.getBucket() in presigned post/put methods

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-24 21:05:16 -04:00
..