Asset

AssetClient

The AssetClient simplifies the process of managing and storing asset metadata for your projects by providing a set of methods to handle file uploads to IPFS (InterPlanetary File System) and create buckets using IPFS providers.

When initializing the KOR SDK, a demo API key is provided by default to allow developers to explore and test its functionalities. However, there are certain limitations when using this demo key:

Demo API Key Limitations

  • File Upload Limit: You can upload a maximum of 5 files using the demo API key.

  • File Size Restriction: The total size of all uploaded files is capped at 50 MB.

To bypass these restrictions for production-level use cases, you need to configure your own API keys for Pinata or Filebase.

Methods

  • uploadAssetToIpfs

  • uploadMetaDataToIpfs

  • createBucket

  • pinFolderToFilebaseIpfs

  • uploadAssetToUrl

uploadAssetToIpfs

Uploads a file to IPFS and returns the CID (Content Identifier).

MethodType

uploadAssetToIpfs

(file, provider, options) => Promise<UploadAssetResponse>

Parameters

NameTypeDescription

file

File

The file to be uploaded to IPFS

provider

'pinata' | 'filebase'

The ipfs service provider to upload and pin files

options

Object

Configuration for the bucket and folder name where the file will be upload (for filebase operations only) Eg: { folderName: 'my-folder', bucketName: 'my-bucket' }

Returns

NameTypeDescription

ipfsHash

string

The CID of the uploaded data

uploadAssetToIpfs

Uploads a folder containing multiple files to IPFS and returns the base CID.

MethodType

uploadAssetToIpfs

(files, provider, options) => Promise<{ipfsHash: string}>

Parameters

NameTypeDescription

file

File

A list of files to be uploaded to IPFS.

provider

'pinata' | 'filebase'

The IPFS service provider to upload and pin files.

options

Object

Configuration for the bucket and folder name where the files will be uploaded. (for filebase operations only) Eg: { folderName: 'my-folder', bucketName: 'my-bucket' }

Returns

NameTypeDescription

ipfsHash

string

The CID of the uploaded data

uploadMetaDataToIpfs

Uploads a metadata JSON file to IPFS and returns the CID.

MethodType

uploadMetaDataToIpfs

(metaData, provider, options) => Promise<{metaDataHash: string}>

Parameters

NameTypeDescription

metaData

Object

The metadata JSON to be uploaded to IPFS.

provider

'pinata' | 'filebase'

The IPFS service provider to upload and pin files.

options

Object

Configuration for the bucket and folder name where the files will be uploaded. (for filebase operations only)

Returns

NameTypeDescription

metaDataHash

string

The CID of the uploaded data

uploadMetaDataToIpfs

Uploads an array of metadata JSON files to IPFS and returns the base CID.

MethodType

uploadMetaDataToIpfs

(metaData, provider, options) => Promise<{metaDataHash: string}>

Parameters

NameTypeDescription

metaData

Object

The metadata JSON to be uploaded to IPFS.

provider

'pinata' | 'filebase'

The IPFS service provider to upload and pin files.

options

Object

Configuration for the bucket and folder name where the files will be uploaded. (for filebase operations only)

Returns

NameTypeDescription

metaDataHash

string

The CID of the uploaded data

createBucket (Filebase function)

Creates a bucket on the Filebase IPFS provider.

MethodType

createBucket

(bucketName: string) => Promise<void>

Parameters

NameTypeDescription

bucketName

string

The name of the bucket to be created.

pinFolderToFilebaseIpfs (Filebase function)

Generates an IPFS CID and pins all files inside a bucket as a folder to IPFS.

MethodType

pinFolderToFilebaseIpfs

(bucketName: string) => Promise<{ipfsHash: string}>

Parameters

NameTypeDescription

bucketName

string

The name of the bucket for which to generate the CID.

Returns

NameTypeDescription

ipfsHash

string

The CID of the uploaded data

uploadAssetToURL

Upload asset to custom BE like S3

MethodType

uploadAssetToURL

(file: File, url: string) => Promise<string>

Parameters

NameTypeDescription

file

File

The file object representing the uploaded file.

url

string

The destination URL for file upload, such as a presigned URL where the file can be directly uploaded.

  • file: File: The file object representing the uploaded file.

  • url: string: The destination URL for file upload, such as a presigned URL where the file can be directly uploaded.

Returns

NameTypeDescription

response

string

The url of the uploaded file

Last updated