Vana SDK - v3.5.0
    Preparing search index...

    Class R2Storage

    Cloudflare R2 storage provider.

    Uses R2's S3-compatible API with SigV4 signed fetch requests, so the same implementation runs in browsers, Node.js, and Workers without pulling in @aws-sdk/client-s3. Treats blobs as opaque - encryption, access control, and per-tenant prefixing are out of scope and live in higher layers.

    The SDK exposes R2 as the recommended default backend. Other providers (Pinata, IPFS, Google Drive, Dropbox, CallbackStorage) remain available for teams that need IPFS semantics or user-owned storage.

    import { R2Storage, StorageManager } from "@opendatalabs/vana-sdk/node";

    const storage = new StorageManager();
    storage.register(
    "r2",
    new R2Storage({
    accountId: process.env.R2_ACCOUNT_ID!,
    accessKeyId: process.env.R2_ACCESS_KEY_ID!,
    secretAccessKey: process.env.R2_SECRET_ACCESS_KEY!,
    bucket: process.env.R2_BUCKET!,
    publicUrl: "https://files.example.com",
    }),
    true,
    );

    const result = await storage.upload(myBlob, "report.json");
    console.log(result.url);

    Implements

    Index

    Methods

    • Upload a file to the storage provider

      Parameters

      • file: Blob

        The file to upload

      • Optionalfilename: string

        Optional custom filename

      Returns Promise<StorageUploadResult>

      Promise with storage URL and metadata

    • List files from the storage provider

      Parameters

      • Optionaloptions: StorageListOptions

        Optional filtering and pagination

      Returns Promise<StorageFile[]>

      Promise with file list

    • Delete a file from the storage provider

      Parameters

      • url: string

        The storage URL

      Returns Promise<boolean>

      Promise with success status