For Developers

For Developers

Lambda provide SDK for developers for easily integrate into web3 application with a few codes

#File Upload

This is a simple demo (opens new window)demonstrates how to upload file or folder

#Installation

yarn install

#Run

//upload file

yarn upload-file

//upload folder

yarn upload-folder

#Integration

  1. 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); });

  1. 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); });

#Submit onchain

#Installation

npm i lambdaupload

#Submit

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.

#Get file size

import { getFileSize } from 'lambdaupload'

await getFileSize({ provider, cid})

Last updated