Skip to content

Feature Request: Integrated Large File/BLOB Storage #2674

@ImGajeed76

Description

@ImGajeed76

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions