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).
Method | Type |
---|---|
|
|
Parameters
Name | Type | Description |
---|---|---|
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:
|
Returns
Name | Type | Description |
---|---|---|
ipfsHash | string | The CID of the uploaded data |
uploadAssetToIpfs
Uploads a folder containing multiple files to IPFS and returns the base CID.
Method | Type |
---|---|
|
|
Parameters
Name | Type | Description |
---|---|---|
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:
|
Returns
Name | Type | Description |
---|---|---|
ipfsHash | string | The CID of the uploaded data |
uploadMetaDataToIpfs
Uploads a metadata JSON file to IPFS and returns the CID.
Method | Type |
---|---|
uploadMetaDataToIpfs |
|
Parameters
Name | Type | Description |
---|---|---|
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
Name | Type | Description |
---|---|---|
metaDataHash | string | The CID of the uploaded data |
uploadMetaDataToIpfs
Uploads an array of metadata JSON files to IPFS and returns the base CID.
Method | Type |
---|---|
uploadMetaDataToIpfs |
|
Parameters
Name | Type | Description |
---|---|---|
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
Name | Type | Description |
---|---|---|
metaDataHash | string | The CID of the uploaded data |
createBucket (Filebase function)
Creates a bucket on the Filebase IPFS provider.
Method | Type |
---|---|
createBucket |
|
Parameters
Name | Type | Description |
---|---|---|
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.
Method | Type |
---|---|
pinFolderToFilebaseIpfs |
|
Parameters
Name | Type | Description |
---|---|---|
bucketName | string | The name of the bucket for which to generate the CID. |
Returns
Name | Type | Description |
---|---|---|
ipfsHash | string | The CID of the uploaded data |
uploadAssetToURL
Upload asset to custom BE like S3
Method | Type |
---|---|
uploadAssetToURL |
|
Parameters
Name | Type | Description |
---|---|---|
file | File | The file object representing the uploaded file. |
| 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
Name | Type | Description |
---|---|---|
response | string | The url of the uploaded file |
Last updated