@way-network/way-ipfs-sdk
v1.1.1
Published
SDKs to interact with Way-IPFS, e.g. upload, download, etc.
Downloads
6
Readme
SDK for Way-IPFS
Install
npm i @way-network/way-ipfs-sdk
Usage
For more info, please have a look on Way-IPFS docs on Notion
import * as waySdk from "@way-network/way-ipfs-sdk";
const urlPrefix = "http://192.168.0.182:3001";
const filePath = "<file-path>";
const uploaderAddress = "0xabc";
const downloaderAddress = "0xdef,0xijk"; // comma separated list of addresses (without spaces)
const encryptId = "0";
const signature = "<your-signature>";
const cid = "<cid>";
waySdk.uploadFile(urlPrefix, filePath, uploaderAddress, encryptId, signature).then((resp) => {
console.log(resp);
});
const fileUrlSuffix = "db29a01786a1fc7e2ddf397311244d71";
const fileOriginalName = "example.js";
const fileMimeType = "application/javascript";
waySdk.uploadFileV2(urlPrefix, fileUrlSuffix, fileOriginalName, fileMimeType, uploaderAddress, encryptId, signature, downloaderAddress).then((resp) => {
console.log(resp);
});
waySdk.downloadFile(urlPrefix, cid, uploaderAddress, uploaderAddress, signature).then((resp) => {
console.log(resp);
});
waySdk.metadata(urlPrefix, cid, uploaderAddress).then((resp) => {
console.log(resp);
});
waySdk.accessControl(urlPrefix, cid, uploaderAddress).then((resp) => {
console.log(resp);
});
const mode = "makePublic"
waySdk.updateAccessControl(urlPrefix, cid, uploaderAddress, signature, mode).then((resp) => {
console.log(resp);
});
waySdk.uploadedFiles(urlPrefix, uploaderAddress).then((resp) => {
console.log(resp);
});