SKALE Filestorage.js
A library for decentralized file storage on SKALE chains.
Install
npm i --save @skalenetwork/filestorage-js
Usage
// Import
const FileStorage = require('@skalenetwork/filestorage-js');
const Web3 = require('web3');
// Setup with web3
const web3Provider = new Web3.providers.HttpProvider('----SKALE ENDPOINT----');
let web3 = new Web3(web3Provider);
let filestorage = new FileStorage(web3);
// Setup with host directly
let filestorage = new FileStorage(host = '----SKALE ENDPOINT----');
Upload file
// Upload file with internal signatures
filestorage.uploadFile(address, fileName, fileSize, fileBuffer, logs, privateKey);
// Upload file with external service (Metamask etc)
filestorage.uploadFile(address, fileName, fileSize, fileBuffer, logs);
Download file to browser
filestorage.downloadFileIntoBrowser(storagePath, logs);
Download file to buffer
filestorage.downloadFileIntoBuffer(storagePath, logs);
Delete file
// Delete file with internal signatures
filestorage.deleteFile(yourAddress, fileName, logs, privateKey);
// Delete file with external service (Metamask etc)
filestorage.deleteFile(yourAddress, fileName, logs);
Get file info
filestorage.getFileInfoByAddress(address);
Contributing
If you have any questions please ask our development community on Discord.