From 09bb42f7a69e83772be906ad6acd0bcc9688bc30 Mon Sep 17 00:00:00 2001 From: Local Dev Date: Fri, 23 Oct 2026 21:33:14 +0300 Subject: [PATCH] prometheus: push scan-clean uploads to Sia, auto-fill the download URL MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Publishers no longer need to self-host. When the service is configured with PROMETHEUS_S3_* credentials pointing at the hosted s3d (s3.silentmode.st), every clean upload is pushed to s3://${bucket}/${prefix}.bin and the public URL comes back on /api/upload as `hosted_url`. Step 2 of the submit form pre-fills the Download URL input with that URL — publishers can overwrite if they prefer their own hosting; by default they ship nothing. - service/s3.js: SigV4 S3 client vendored from Pithos/core/s3.js so bug fixes port by file-copy. Path-style, UNSIGNED-PAYLOAD streaming PUT, Content-Length required (s3d chunked encoding does not round-trip cleanly for large bodies). - service/storage.js: thin wrapper exposing isConfigured() and uploadScannedFile(). Idempotent on sha256 — same bytes → same key. Failure is non-fatal; the publisher can still paste their own URL. - service/uploads.js: after rename-to-final, push to Sia if configured. Added `hosted_url` to the response (null when storage off). - service/pages.js: step 2 pre-fills download_url when hosted_url is present; hint text explains the override path. - docker-compose.yml: PROMETHEUS_S3_* env plumbed through, with sane defaults for bucket/prefix (bns + prometheus-storage/). --- deploy/docker-compose.yml | 10 ++ service/pages.js | 14 ++- service/s3.js | 259 ++++++++++++++++++++++++++++++++++++++ service/storage.js | 127 +++++++++++++++++++ service/uploads.js | 28 +++++ 5 files changed, 437 insertions(+), 1 deletion(-) create mode 100644 service/s3.js create mode 100644 service/storage.js diff --git a/deploy/docker-compose.yml b/deploy/docker-compose.yml index 679ace5..903119d 100644 --- a/deploy/docker-compose.yml +++ b/deploy/docker-compose.yml @@ -32,6 +32,16 @@ services: PROMETHEUS_PAYMENT_ADDRESS: ${PROMETHEUS_PAYMENT_ADDRESS:-} PROMETHEUS_LISTING_FEE_USD: ${PROMETHEUS_LISTING_FEE_USD:-1} BNS_GATEWAY: ${BNS_GATEWAY:-} + # Sia-backed storage: when set, scan-clean uploads are pushed to the + # hosted s3d and the submit UI pre-fills the download URL. All four + # must be set for storage to turn on; otherwise publishers host + # their own binaries. See service/storage.js for defaults. + PROMETHEUS_S3_ENDPOINT: ${PROMETHEUS_S3_ENDPOINT:-} + PROMETHEUS_S3_ACCESS_KEY: ${PROMETHEUS_S3_ACCESS_KEY:-} + PROMETHEUS_S3_SECRET: ${PROMETHEUS_S3_SECRET:-} + PROMETHEUS_S3_BUCKET: ${PROMETHEUS_S3_BUCKET:-bns} + PROMETHEUS_S3_PREFIX: ${PROMETHEUS_S3_PREFIX:-prometheus-storage/} + PROMETHEUS_PUBLIC_BASE: ${PROMETHEUS_PUBLIC_BASE:-} volumes: - data:/data networks: diff --git a/service/pages.js b/service/pages.js index 6292c29..a40e797 100644 --- a/service/pages.js +++ b/service/pages.js @@ -506,7 +506,7 @@ export function submit() {