Skip to content

feat: add presigned URL redirect for blob storage streaming#194

Merged
raymondjacobson merged 5 commits intomainfrom
ray/blob-storage-streaming
Apr 2, 2026
Merged

feat: add presigned URL redirect for blob storage streaming#194
raymondjacobson merged 5 commits intomainfrom
ray/blob-storage-streaming

Conversation

@raymondjacobson
Copy link
Copy Markdown
Contributor

feat: add presigned URL redirect for blob storage streaming

When OPENAUDIO_BLOB_STORAGE_STREAMING=true and the storage backend
supports presigned URLs (S3/GCS), redirect stream requests directly
to the storage backend via HTTP 307 instead of proxying bytes through
the server. This reduces CPU, memory, and I/O load on content nodes.

  • Duration-aware expiry: looks up track duration from uploads table
    FFProbe data (with functional index for fast lookup), computes
    expiry as duration * 1.1 with a 5-minute floor and 2-hour default
  • Graceful fallback: if SignedURL fails, falls through to normal proxy
  • Skips presigned URLs for ID3-tagged streams and download requests
  • Feature is off by default, only activates for s3://, https://, gs://

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

test: add unit tests for presigned URL logic

Tests for supportsPresignedURLs(), presignedURLExpiry(), and the
combined feature flag + DSN computation. Covers all storage backends,
duration edge cases (unknown, short, long, DJ mixes), and floor/default
behavior.

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

raymondjacobson and others added 2 commits April 1, 2026 23:05
When OPENAUDIO_BLOB_STORAGE_STREAMING=true and the storage backend
supports presigned URLs (S3/GCS), redirect stream requests directly
to the storage backend via HTTP 307 instead of proxying bytes through
the server. This reduces CPU, memory, and I/O load on content nodes.

- Duration-aware expiry: looks up track duration from uploads table
  FFProbe data (with functional index for fast lookup), computes
  expiry as duration * 1.1 with a 5-minute floor and 2-hour default
- Graceful fallback: if SignedURL fails, falls through to normal proxy
- Skips presigned URLs for ID3-tagged streams and download requests
- Feature is off by default, only activates for s3://, https://, gs://

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Tests for supportsPresignedURLs(), presignedURLExpiry(), and the
combined feature flag + DSN computation. Covers all storage backends,
duration edge cases (unknown, short, long, DJ mixes), and floor/default
behavior.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@raymondjacobson raymondjacobson marked this pull request as ready for review April 2, 2026 06:12
raymondjacobson and others added 2 commits April 1, 2026 23:29
…te handleConsensusCheck

The 3-minute track test expected 198s but 198s < 5min floor, so the
correct expectation is the 5-minute minimum. Also removes the duplicate
handleConsensusCheck function from main.go (already extracted to
consensus_check.go) which was causing build failures.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The `openaudio` gitignore pattern causes files in cmd/openaudio/ to be
ignored. consensus_check.go was created but never force-added to git,
so CI only had main.go which referenced the missing function.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Comment thread pkg/mediorum/server/server.go Outdated
// supportsPresignedURLs returns true if the storage backend supports generating presigned URLs.
// S3, S3-compatible (https), and GCS backends support this. File and Azure backends do not.
func supportsPresignedURLs(dsn string) bool {
for _, prefix := range []string{"s3://", "https://", "gs://"} {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this definitely true of all implementations of S3-compatible blob storage? wondering if this should instead be a separate config w/ some validation to fail fast

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there's a separate env var to gate the field so i think it's enough, but maybe just remove this and keep the env var?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah yeah i see that now. and yeah i think if you enable that env var but are using an "invalid" url, we should either throw or do nothing and let it "fail" vs silently not doing the thing you configured it to do

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good call. will make that change

…errors

Instead of checking the DSN prefix via supportsPresignedURLs(), the
BlobStorageStreaming config flag now directly controls whether presigned
URL redirects are attempted. If SignedURL() fails at runtime, the node
returns a 500 error instead of silently falling back to proxying, making
misconfiguration immediately visible.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@raymondjacobson raymondjacobson merged commit 51bbecc into main Apr 2, 2026
7 checks passed
@raymondjacobson raymondjacobson deleted the ray/blob-storage-streaming branch April 2, 2026 20:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants