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.
Steps to configure your own pinata API keys:
Step 1: Create API Key

Step 2: Copy JWT (secret access token)

Step 3: Paste it in your profile dashboard
Steps to configure filebase API keys:
Step 1: Go to filebase console and then go to access keys Step 2: Copy Key and Secret

Step 3: Paste it in your profile dashboard
Methods
uploadAssetToIpfs
uploadMetaDataToIpfs
createBucket
pinFolderToFilebaseIpfs
uploadAssetToUrl
uploadAssetToIpfs
Uploads a file to IPFS and returns the CID (Content Identifier).
uploadAssetToIpfs
(file, provider, options) => Promise<UploadAssetResponse>
Parameters
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
ipfsHash
string
The CID of the uploaded data
uploadAssetToIpfs
Uploads a folder containing multiple files to IPFS and returns the base CID.
uploadAssetToIpfs
(files, provider, options) => Promise<{ipfsHash: string}>
Parameters
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
ipfsHash
string
The CID of the uploaded data
uploadMetaDataToIpfs
Uploads a metadata JSON file to IPFS and returns the CID.
uploadMetaDataToIpfs
(metaData, provider, options) => Promise<{metaDataHash: string}>
Parameters
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
metaDataHash
string
The CID of the uploaded data
uploadMetaDataToIpfs
Uploads an array of metadata JSON files to IPFS and returns the base CID.
uploadMetaDataToIpfs
(metaData, provider, options) => Promise<{metaDataHash: string}>
Parameters
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
metaDataHash
string
The CID of the uploaded data
createBucket (Filebase function)
Creates a bucket on the Filebase IPFS provider.
createBucket
(bucketName: string) => Promise<void>
Parameters
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.
pinFolderToFilebaseIpfs
(bucketName: string) => Promise<{ipfsHash: string}>
Parameters
bucketName
string
The name of the bucket for which to generate the CID.
Returns
ipfsHash
string
The CID of the uploaded data
uploadAssetToURL
Upload asset to custom BE like S3
uploadAssetToURL
(file: File, url: string) => Promise<string>
Parameters
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
response
string
The url of the uploaded file
Last updated