@welshare/sdk
    Preparing search index...

    Function deleteBinaryFile

    • Delete a binary file from the user's storage.

      This deletes both the metadata record in Nillion and the encrypted file in S3. The deletion happens in three steps:

      1. Fetch a presigned S3 DELETE URL via delegation
      2. Call the presigned URL from the client side (browser)
      3. Delete from Nillion using userClient (works even if API is down)

      Parameters

      • keypair: SessionKeypair

        The user's session keypair for authentication

      • binaryFileId: string

        The document ID of the binary file to delete

      • environment: WelshareApiEnvironment

        The Welshare API environment configuration

      Returns Promise<void>

      Promise that resolves when the file is deleted

      import { WelshareApi, resolveEnvironment } from "@welshare/sdk";

      await WelshareApi.deleteBinaryFile(
      keypair,
      "abc-123-def-456",
      resolveEnvironment("production")
      );

      Side effects:

      • Fetches presigned DELETE URL via {apiUrl}/auth/delegate/storage?requestType=delete
      • Calls the presigned URL to delete the encrypted file from S3 storage
      • Deletes the binary file metadata from Nillion using userClient

      Security notes:

      • Only the file owner (controller_did) can delete their files
      • Presigned URLs expire after 15 seconds

      Error handling:

      • If S3 deletion fails but Nillion deletion succeeds, the function logs a warning but doesn't throw
      • This allows users to delete their data from Nillion even if the storage backend has issues