bb-plane-fork/apps/web
binarybeach 9fb1ad44cd binarybeachio: presigned PUT for uploads (R2/B2 don't implement PostObject)
== WHY (KEEP THIS — IT'S WHY THE FORK EXISTS) ==

Vanilla Plane's upload flow uses AWS S3 PostObject (presigned POST +
multipart/form-data + signed-policy-document). Cloudflare R2 AND
Backblaze B2 — the two most common self-host S3-compatible backends —
both return HTTP 501 NotImplemented for PostObject. Empirically verified
2026-04-30 against B2 s3.us-west-004.backblazeb2.com from inside Plane's
own prod api container, replicating Plane's exact boto3 call:

  PUT against B2:  200 OK
  POST against B2: 501 NotImplemented "This API call is not supported."
  POST against R2: 501 NotImplemented (failure that started this thread)

The error code is `NotImplemented` (not `SignatureDoesNotMatch` etc),
meaning the server rejects the verb itself — no boto3 config, addressing-
style flag, or signature variant fixes it. Tested both path-style and
virtual-hosted-style URLs against B2; both fail identically for POST.

This patch rewrites the upload flow to use presigned PUT, which is
universally supported (R2, B2, AWS S3 native, MinIO, Wasabi, etc).

== WHAT (FIVE-FILE BACKEND, FIVE-FILE FRONTEND) ==

Backend:
* apps/api/plane/settings/storage.py — S3Storage.generate_presigned_post
  now mints a presigned PUT URL via generate_presigned_url(HttpMethod="PUT").
  Method name kept for caller compat. Response shape:
  {url, method: "PUT", fields: {Content-Type, key}}.
* apps/api/plane/utils/openapi/responses.py — example response updated.
* apps/api/plane/tests/unit/settings/test_storage.py — 2 tests updated to
  assert the new boto3 call.

Frontend:
* packages/types/src/file.ts — TFileSignedURLResponse.upload_data adds
  optional method?: "PUT" | "POST"; drops AWS POST-form-data fields.
* packages/services/src/file/helper.ts — generateFileUploadPayload now
  returns a TFileUploadRequest descriptor (url+method+body+headers) that
  dispatches on method. POST branch kept for upstream parity but the
  fork backend never emits POST.
* packages/services/src/file/file-upload.service.ts +
  apps/web/core/services/file-upload.service.ts — uploadFile signature
  changes from (url, FormData, progress?) to (payload, progress?).
* 5 caller sites updated (apps/web/core/services/file.service.ts x3,
  issue_attachment.service.ts x1, sites-file.service.ts x1).

== TRADEOFFS ACCEPTED ==

* Lost: signed `content-length-range` enforcement at the storage layer.
  Server-side validation in the API view still rejects oversized requests
  with 413 before minting the URL, so a determined client could only
  over-upload by misreporting size, capped at the bucket's own size limit.
* Different request shape on the wire (PUT with raw binary body vs POST
  with multipart form). Externally invisible to users.

== ROLLBACK ==

If this becomes a maintenance nightmare:

  git revert <this-commit-sha>
  # rebuild + push images, swap compose tags, redeploy

After revert, uploads will only work against backends that implement
PostObject (MinIO, AWS S3 native). R2 and B2 will return 501 again.

== FULL DECISION RECORD ==

binarybeachio repo: docs/features/storage-upload-flow.md

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-30 17:56:52 -10:00
..
app binarybeachio: account chooser, brand logo, session convention 2026-04-30 14:51:21 -10:00
ce fix: remove unused imports and variables (part 1 — packages & non-web-core) (#8751) 2026-03-25 02:04:20 +05:30
core binarybeachio: presigned PUT for uploads (R2/B2 don't implement PostObject) 2026-04-30 17:56:52 -10:00
helpers [WEB-6794] fix: align profile cover update with correct unsplash and upload handling (#8830) 2026-03-31 15:54:12 +05:30
nginx [VPAT-50] chore(security): add X-Frame-Options header to nginx configuration to prevent clickjacking attacks (#8507) 2026-01-09 04:03:41 +05:30
public fix: eslint (#8185) 2025-12-05 16:03:51 +05:30
styles [WEB-5675] chore: implement fontsource as the fonts library (#8398) 2025-12-19 16:21:04 +05:30
.dockerignore [WEB-5043] feat: web vite migration (#7973) 2025-11-06 14:08:48 +05:30
.env.example [WEB-5413] feat: adding sentry error handling in web, space and admin (#8099) 2025-11-12 19:03:47 +05:30
.gitignore chore: move all services inside the apps folder (#7321) 2025-07-03 00:44:13 +05:30
.prettierignore fix: eslint (#8185) 2025-12-05 16:03:51 +05:30
Dockerfile.dev feat: migrate to pnpm from yarn (#7593) 2025-08-19 20:06:42 +05:30
Dockerfile.web chore: upgrade turbo from v2.8.12 to v2.9.4 (#8859) 2026-04-06 16:04:57 +05:30
google.d.ts chore: run fixes (#8257) 2025-12-08 22:26:50 +05:30
manifest.json chore: move all services inside the apps folder (#7321) 2025-07-03 00:44:13 +05:30
package.json chore: version bump 2026-03-31 17:09:35 +05:30
postcss.config.js [WEB-5602] feat: new design system (#8220) 2025-12-12 20:50:14 +05:30
react-router.config.ts [WEB-5386] refactor: update all apps to use react-router for development and enable SSR for space app. (#8095) 2025-11-11 14:08:42 +05:30
tsconfig.json fix: remove ee folder from web (#8622) 2026-02-10 20:01:42 +05:30
use-font-face-observer.d.ts chore: move all services inside the apps folder (#7321) 2025-07-03 00:44:13 +05:30
vite.config.ts chore(deps): replace dotenvx with dotenv and update overrides (#8832) 2026-03-31 16:55:17 +05:30