clockworklabs / clockworklabs/SpacetimeDB
Feature Request: Integrated Large File/BLOB Storage
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 25.2k
- Forks
- 1.1k
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 46
Description
Requesting built-in support for storing large binary files (images, documents, game assets, etc.) directly within SpacetimeDB, managed separately from the primary in-memory store to preserve real-time performance.
Currently, handling large files requires external object storage (like S3) and storing only references (URLs/IDs) in SpacetimeDB tables, adding architectural complexity and external dependencies.
Proposed Feature:
- Storage: Introduce a built-in function, usable within reducers, to accept binary data (
Bytes,Vec<u8>, etc.) and store it efficiently (e.g., on disk or an integrated backend). This function would return a stable reference (BlobRef).// Hypothetical reducer #[spacetimedb(reducer)] fn upload_asset(ctx: ReducerContext, asset_id: u32, asset_data: Bytes) { // Built-in function stores blob, returns reference if let Ok(blob_ref) = spacetimedb::blob::store(asset_data) { // Store reference in a regular table GameAsset::insert(ctx, GameAsset { asset_id, data_ref: blob_ref, .. }); } } - Retrieval: Provide a mechanism to retrieve the file using its
BlobRef. Ideally, this would expose a stable URL (e.g., via SpacetimeDB's HTTP server) that clients can use to download the file directly, handling authentication appropriately. Server-side retrieval might also be possible.
Benefits:
- Simplified Architecture: Reduces the need for separate external file storage services, simplifying deployment and management.
- Integrated Management: Keeps relational data and associated files managed more cohesively within the SpacetimeDB ecosystem.
- Game Development Advantages:
- User-Generated Content (UGC): Easily store player-created content like custom maps, skins, or avatars directly linked to player accounts or game state.
- Game Assets: Manage dynamic game assets (e.g., downloadable content, patches, configuration files) associated with game versions or player entitlements.
- Replays/Save States: Store potentially large game replay files or complex save states directly linked to match IDs or user profiles.
- Reduced Latency Perception: While storage/retrieval might not be real-time, integrating it simplifies the developer workflow for associating these assets with the real-time game state managed by SpacetimeDB.
This feature would streamline development, particularly for games and applications needing to associate large files with their core SpacetimeDB data, by removing the need to manage separate storage infrastructure.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by surveying SpacetimeDB's existing storage, reducer, and HTTP server entry points; the issue does not name specific files or tests. Compare how external object-storage references are currently handled and determine the required BlobRef, persistence, retrieval, and authentication design. Done means an agreed implementation scope and corresponding tests for storing and retrieving large binary data.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- backend, databases
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100