Vana SDK - v0.1.0
    Preparing search index...

    Provides managed IPFS storage with full-featured API via Pinata

    This provider uses Pinata's enhanced IPFS service, which extends standard IPFS with additional features like file listing, deletion (unpinning), and rich metadata. It's the "it just works" solution for developers who want full CRUD operations on IPFS without managing infrastructure.

    const pinataStorage = new PinataStorage({
    jwt: "your-pinata-jwt-token"
    });

    // Upload with metadata
    const cid = await pinataStorage.upload(fileBlob, {
    name: "user-avatar.png",
    metadata: { userId: "123", category: "avatar" }
    });

    // List files with query
    const files = await pinataStorage.list({ limit: 10 });

    // Delete file
    await pinataStorage.delete(cid);

    Implements

    Index

    Methods

    • Uploads a file to IPFS via Pinata and returns the CID

      Parameters

      • file: Blob

        The file to upload to IPFS

      • Optionalfilename: string

        Optional custom filename

      Returns Promise<StorageUploadResult>

      Promise that resolves to the IPFS CID (content identifier)

      This method uploads the file to Pinata's IPFS service with enhanced metadata support. The file is pinned to ensure availability and can include custom metadata for organization and querying. The metadata is stored alongside the file for later retrieval.

      When the upload fails or no CID is returned

      const cid = await pinataStorage.upload(fileBlob, {
      name: "user-document.pdf",
      metadata: {
      userId: "user-123",
      category: "documents",
      uploadDate: new Date().toISOString()
      }
      });
      console.log("File pinned to IPFS:", cid);
    • Lists files uploaded to Pinata with optional filtering

      Parameters

      • Optionaloptions: StorageListOptions

        Optional query parameters for filtering and pagination

        • limit

          Maximum number of results to return (default: 10)

        • offset

          Number of results to skip for pagination

        • namePattern

          Filter files by name pattern

      Returns Promise<StorageFile[]>

      Promise that resolves to an array of PinataFile objects

      This method retrieves a list of files that have been uploaded to Pinata, filtered to only include files uploaded by the Vana SDK. You can further filter results by name pattern, limit results, or paginate through them.

      When the list operation fails

      // List all files
      const allFiles = await pinataStorage.list();

      // List with pagination and filtering
      const filteredFiles = await pinataStorage.list({
      limit: 20,
      offset: 10,
      namePattern: "document"
      });

      filteredFiles.forEach(file => {
      console.log(`${file.name} (${file.size} bytes): ${file.cid}`);
      });
    • Deletes a file from Pinata by unpinning it from IPFS

      Parameters

      • url: string

        The IPFS URL or content identifier of the file to delete

      Returns Promise<boolean>

      Promise that resolves when the file is successfully unpinned

      This method removes the file from your Pinata account by unpinning it, which means it will no longer be guaranteed to be available on the IPFS network. Note that if the file is pinned elsewhere or cached by other nodes, it may still be accessible for some time.

      When the deletion fails or CID format is invalid

      // Delete a file by CID
      await pinataStorage.delete("QmTzQ1JRkWErjk39mryYw2WVrgBMe2B36gRq8GCL8qCACj");
      console.log("File unpinned from Pinata");

      // Delete after listing
      const files = await pinataStorage.list();
      for (const file of files) {
      if (file.name.includes("temp")) {
      await pinataStorage.delete(file.cid);
      }
      }