From e79595b902f0a3d8a791a16c13f9325422403ec9 Mon Sep 17 00:00:00 2001 From: thePR0M3TH3AN <53631862+PR0M3TH3AN@users.noreply.github.com> Date: Tue, 30 Jun 2026 10:05:53 -0400 Subject: [PATCH] [storage] #38: add Backblaze B2 as a first-class storage provider MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit B2 doesn't map onto the generic-S3 "paste an endpoint" model: its S3-compatible endpoint is region-scoped (s3..backblazeb2.com) and a public bucket is addressed virtual-hosted-style, so the public download URL is https://.s3..backblazeb2.com/ — not derivable from a pasted generic endpoint. So B2 silently failed under "Custom S3". - s3-url: deriveB2Endpoint(region) -> https://s3..backblazeb2.com (empty for auto/blank/pasted-host so callers can require a real region); re-exported from s3Service. - storageService: PROVIDERS.B2 + resolveB2Endpoint (explicit endpoint wins, else derive) + PROVIDER_TESTS[B2] (derived endpoint, forcePathStyle false). - Public URL = S3-style virtual-hosted, auto-derived; an explicit Public Access URL (custom domain/CDN) overrides it. The save path now forwards the user's public URL to prepareS3Connection (also fixes generic-S3 ignoring a custom CDN URL when blank -> still derives, so no regression). - UI: "Backblaze B2" provider option + helper; raw Endpoint hidden for B2 (region drives it), region shows a us-west-004 example, force-path-style toggle hidden; save/test derive endpoint from region with a clear "enter your region" error. UploadModal shows B2-specific labels. - Tests: tests/storage-b2-provider.test.mjs (8). All s3/storage suites green (50); build + lint clean. Co-Authored-By: Claude Opus 4.8 --- components/profile-modal.html | 6 + js/services/s3Service.js | 3 + js/services/storageService.js | 21 ++++ js/storage/s3-url.js | 19 +++ js/ui/components/UploadModal.js | 6 + .../profileModal/ProfileStorageController.js | 79 +++++++++++-- tests/storage-b2-provider.test.mjs | 111 ++++++++++++++++++ todo/TODO_2026-06-20_pre-launch.md | 33 ++++-- 8 files changed, 259 insertions(+), 19 deletions(-) create mode 100644 tests/storage-b2-provider.test.mjs diff --git a/components/profile-modal.html b/components/profile-modal.html index 1f19b708..bf2f614d 100644 --- a/components/profile-modal.html +++ b/components/profile-modal.html @@ -898,6 +898,7 @@ Provider @@ -907,6 +908,11 @@ Enter your Cloudflare R2 credentials. Your Account ID (from dashboard) is used to connect. For Public Access URL, use your custom domain or R2.dev subdomain. Ensure the token has "Object Read & Write" permissions. + + +