icp-file
v1.0.1
Published
**icp-file** is a client library that allows users to upload and download any type of file on the blockchain (ICP). It supports caching for efficient data retrieval and management, providing a seamless experience for interacting with blockchain storage.
Downloads
3
Maintainers
Readme
icp-file
icp-file is a client library that allows users to upload and download any type of file on the blockchain (ICP). It supports caching for efficient data retrieval and management, providing a seamless experience for interacting with blockchain storage.
Features
- Upload Files: Easily upload files of any type to the blockchain.
- Download Files: Securely download files from the blockchain.
- Caching Support: Efficient caching mechanisms to speed up file access and reduce redundant network requests.
- Blockchain Integration: Seamlessly integrates with blockchain technology for secure and decentralized file storage.
Installation
To install the icp-file
package, use npm:
npm install icp-file
#Usage
import {icpFile} from "icp-file"
//configure it
icfFile.config({
canister:...,
idlFactory : ....,
})
//or if you have an agent already
icpFile.configure({agent: your agent})
// to upload a video do
const fileInfo = {
id: file.name,
fileName: file.name,
mimeType: file.type,
size: file.size,
chunkCount: 0,
allChunksUploaded: false
};
await icpFile.uploadVideoFile(file, fileInfo, onUploadFunction);
// to get the file
let result = await icpFile.getVideo();
let videoObjectUrl = icpfile.getFileObjectUrl(result);
Then in your HTML
<video src = {videoObjecturl} />