For Developers
Last updated
Was this helpful?
Last updated
Was this helpful?
Lambda provide SDK for developers for easily integrate into web3 application with a few codes
This is a simple demonstrates how to upload file or folder
yarn install
//upload file
yarn upload-file
//upload folder
yarn upload-folder
How to upload file
const LambdaStorage = require('./LambdaStorage');
const filePath = './data/file-to-upload.png';
const lambdaStorage = new LambdaStorage();
console.log(Uploading ${filePath}...
);
lambdaStorage.upload(filePath).then((response) => { console.log(response); }).catch((error) => { console.log(error); });
How to upload folder
const LambdaStorage = require('./LambdaStorage');
const folderPath = './data/folder-to-upload/';
const lambdaStorage = new LambdaStorage();
console.log(Uploading folder ${folderPath}...
);
lambdaStorage.upload(folderPath,true).then((response) => { console.log(response); }).catch((error) => { console.log(error); });
npm i lambdaupload
You need to provide account address, file name, cid and filesize
import { uploadFiles } from 'lambdaupload'
await uploadFiles({ provider, account, name, cid, filesize })
You need to submit the actual file/folder size, otherwise storage node will refuse to provide data availability for mismatch size.
import { getFileSize } from 'lambdaupload'
await getFileSize({ provider, cid})