buzz icon indicating copy to clipboard operation
buzz copied to clipboard

Proposal: Graceful cloud storage fallback (Google Drive / S3) when media servers return 5xx errors

Open ranjank2alpha opened this issue 3 months ago • 0 comments

Problem Statement

During Blossom / NIP-96 / relay media store outages, quota exhaustion, or server errors (HTTP 500, 502, 503, 504), attachment uploads fail completely with a hard error.

When a media server goes down:

  • Users cannot share documents, images, or media files within the chat timeline.
  • The workflow is interrupted, forcing users to manually upload files via a third-party service, copy links, and paste raw URLs into the message composer.

Proposed Solution

Introduce an intelligent fallback mechanism in the desktop media upload pipeline:

  1. Availability Error Detection: Pure detector (\isRelayUnavailableError) that intercepts HTTP 5xx responses (500, 502, 503, 504) and server availability timeouts while leaving 4xx client rejections untouched.
  2. Graceful Cloud Routing:
    • If an external cloud storage provider (e.g., Google Drive, S3/R2) is connected, automatically route the upload to the user's storage provider.
    • Format the resulting upload link into the standard timeline attachment schema so other community members can preview or download the file seamlessly.
  3. Opt-in / Configuration:
    • If no provider is configured, surface a non-blocking toast with a direct action to link external cloud storage in Settings for fallback resilience.

Architecture

  • Detector: Lightweight status checker in the upload pipeline.
  • Provider Interface: Pluggable storage abstraction allowing multiple storage adapters (Google Drive, S3-compatible endpoints, etc.).
  • Timeline Integration: Rich attachment card formatting for externally hosted files.

Discussion & Maintainer Feedback

  • Would upstream prefer a general pluggable storage fallback interface in \desktop/?
  • What cloud storage providers would be most beneficial as default reference implementations (e.g., Google Drive, S3/R2 presigned uploads)?

We have implemented and validated this pattern in our builds during live relay outages with zero regressions in the standard Blossom/relay path. Happy to open a dedicated PR based on maintainer guidance.

ranjank2alpha avatar Aug 31 '26 09:08 ranjank2alpha