Options
All
  • Public
  • Public/Protected
  • All
Menu

Aggregated API to work with IPFS: get the content of the spaces of posts and profiles.

Hierarchy

  • SubsocialIpfsApi

Index

Constructors

constructor

Properties

Private ipfsNodeUrl

ipfsNodeUrl: string

IPFS node readonly gateway

Private offchainUrl

offchainUrl: string

Offchain gateway

Private Optional useServer

useServer: UseServerProps

Methods

findComment

  • findComment(cid: IpfsCid): Promise<CommonPostContent>
  • Find and load off-chain information about a comment from IPFS by a given cid.

    Comment information only exists if there is a corresponding JSON file that represents the comment's content on IPFS.

    Parameters

    • cid: IpfsCid

      IPFS content id of a desired comment.

    Returns Promise<CommonPostContent>

    Data about a desired comment from IPFS. If no corresponding comments to given id, undefined is returned.

findComments

  • findComments(cids: IpfsCid[]): Promise<Record<string, CommonPostContent>>
  • Find and load an array of off-chain information about comments from IPFS by a given array of cids.

    Comment information only exists if there is a corresponding JSON file that represents the comments' content on IPFS.

    Parameters

    • cids: IpfsCid[]

      An array of IPFS content ids of desired comments.

    Returns Promise<Record<string, CommonPostContent>>

    An array of data about desired comments from IPFS. If no corresponding comments to given array of cids, an empty array is returned.

findPost

  • Find and load off-chain information about a post from IPFS by a given cid.

    Post information only exists if there is a corresponding JSON file that represents the post's content on IPFS.

    Parameters

    • cid: IpfsCid

      IPFS content id of a desired post.

    Returns Promise<PostContent>

    Data about a desired post from IPFS. If no corresponding post to given id, undefined is returned.

findPosts

  • Find and load an array of off-chain information about posts from IPFS by a given array of cids.

    Post information only exists if there is a corresponding JSON file that represents the posts' content on IPFS.

    Parameters

    • cids: IpfsCid[]

      An array of IPFS content ids of desired posts.

    Returns Promise<Record<string, PostContent>>

    An array of data about desired posts from IPFS. If no corresponding posts to given array of cids, an empty array is returned.

findProfile

  • Find and load off-chain information about a profile from IPFS by a given cid.

    Profile information only exists if there is a corresponding JSON file that represents the profile's content on IPFS.

    Parameters

    • cid: IpfsCid

      IPFS content id of a desired profile.

    Returns Promise<ProfileContent>

    Data about a desired profile from IPFS. If no corresponding profiles to given id, undefined is returned.

findProfiles

  • Find and load an array of off-chain information about profiles from IPFS by a given array of cids.

    Profile information only exists if there is a corresponding JSON file that represents the profiles' content on IPFS.

    Parameters

    • cids: IpfsCid[]

      An array of IPFS content ids of desired profiles.

    Returns Promise<Record<string, ProfileContent>>

    An array of data about desired profiles from IPFS. If no corresponding profiles to given array of cids, an empty array is returned.

findSpace

  • Find and load off-chain information about a space from IPFS by a given cid.

    Space information only exists if there is a corresponding JSON file that represents the space's content on IPFS.

    Parameters

    • cid: IpfsCid

      IPFS content id of a desired space.

    Returns Promise<SpaceContent>

    Data about a desired space from IPFS. If no corresponding space to given id, undefined is returned.

findSpaces

  • Find and load an array of off-chain information about spaces from IPFS by a given array of cids.

    Space information only exists if there is a corresponding JSON file that represents the spaces' content on IPFS.

    Parameters

    • cids: IpfsCid[]

      An array of IPFS content ids of desired spaces.

    Returns Promise<Record<string, SpaceContent>>

    An array of data about desired spaces from IPFS. If no corresponding spaces to given array of cids, an empty array is returned.

getContent

  • getContent<T>(cid: IpfsCid, contentName?: string): Promise<T>

getContentArray

  • getContentArray<T>(cids: IpfsCid[], contentName?: string): Promise<Record<string, T>>

getContentArrayFromIpfs

  • getContentArrayFromIpfs<T>(cids: IpfsCid[], contentName?: string): Promise<Record<string, T>>

getContentArrayFromOffchain

  • getContentArrayFromOffchain<T>(cids: IpfsCid[], contentName?: string): Promise<Record<string, T>>

getUniqueCids

  • getUniqueCids(cids: IpfsCid[], contentName?: string): CID[]

Private ipfsNodeRequest

  • ipfsNodeRequest(endpoint: IpfsNodeEndpoint, cid?: CID): Promise<AxiosResponse<any>>
  • Makes a request to the IPFS node

    Parameters

    • endpoint: IpfsNodeEndpoint
    • Optional cid: CID

    Returns Promise<AxiosResponse<any>>

removeContent

  • removeContent(cid: IpfsCid): Promise<void>

saveComment

  • saveComment(content: CommonPostContent): Promise<IpfsCid>

saveContent

saveFile

  • saveFile(file: File | Blob): Promise<any>

savePost

saveSpace

Private testConnection

  • testConnection(): Promise<void>