Class IPFS

Class for handling IPFS file uploads through various providers

Constructors

Properties

Methods

Constructors

  • Creates an instance of the IPFS class

    Parameters

    • provider: providers

      The IPFS provider to use ('pinata' or 'filebase')

    • config: ProviderConfig

      Configuration for the selected provider

    Returns IPFS

Properties

provider: providers

Methods

  • Uploads a file to IPFS (Node.js version - accepts file path)

    Parameters

    • file: string

      Path to the file to upload

    • Optional fileName: string

      Name to use for the file

    Returns Promise<string>

    Promise resolving to the IPFS content identifier (CID)

    Throws

    Error if provider is not supported or upload fails

  • Uploads a file to IPFS (Browser version - accepts File object)

    Parameters

    • file: File

      File object to upload

    • Optional fileName: string

      Name to use for the file (optional, will use file.name if not provided)

    Returns Promise<string>

    Promise resolving to the IPFS content identifier (CID)

    Throws

    Error if provider is not supported or upload fails

  • Uploads a JSON object to IPFS Supports multiple providers: Pinata and Filebase

    Parameters

    • json: object

      The JSON object to upload

    • Optional fileName: string

      Name to use for the file

    Returns Promise<string>

    Promise resolving to the IPFS content identifier (CID)

    Throws

    Error if provider is not supported or upload fails