-
Notifications
You must be signed in to change notification settings - Fork 607
Open
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.
Lethalchip, egormanga and JaniMcloutiertyler and JaniMGGAlanSmithee
Metadata
Metadata
Assignees
Labels
No labels