@lumera/sdk-js
    Preparing search index...

    Class CascadeUploader

    CascadeUploader manages the complete file upload workflow.

    This class integrates all components of the storage layer to provide a simple, high-level API for uploading files to Cascade. It handles:

    • File hashing and integrity verification
    • RaptorQ layout generation
    • LEP-1 compliant index file construction
    • Upload task initiation and monitoring
    Index

    Constructors

    Methods

    Constructors

    Methods

    • Upload a file to Cascade storage

      This method orchestrates the complete upload workflow:

      1. Fetches action parameters from the blockchain (max_raptor_q_symbols)
      2. Generates a random initial counter (rq_ids_ic) for layout ID derivation
      3. Converts the file to bytes and calculates data_hash (BLAKE3)
      4. Generates a single-block RaptorQ layout using rq-wasm
      5. Derives layout IDs per LEP-1 specification
      6. Constructs the index file with layout metadata
      7. Registers the action on-chain via single-call transaction flow
      8. Signs hash of file bytes to create start_signature
      9. Initiates upload via sn-api with multipart form data
      10. Monitors the upload task until completion
      11. Returns the completed task details

      Parameters

      • file: ArrayBuffer | Uint8Array<ArrayBufferLike> | Blob

        The file to upload (as Blob, ArrayBuffer, or Uint8Array)

      • params: UploadParams

        Upload parameters including action ID

      Returns Promise<{ progress?: number; status?: string; taskId?: string }>

      Promise resolving to the completed upload task

      If any step of the upload workflow fails

      const uploader = new CascadeUploader(snapiClient, chainPort);

      // Upload from a file input
      const fileInput = document.querySelector('input[type="file"]');
      const file = fileInput.files[0];

      const result = await uploader.uploadFile(file, {
      actionId: 'action-123',
      taskOptions: {
      pollInterval: 2000,
      timeout: 300000
      }
      });

      console.log('Upload complete:', result);