Lambda
  • ABOUT LAMBDA
    • Introduction
    • Architecture
  • FOR USER
    • Chain Info
    • Token Info
    • Migrate(LAMB-LAMBDA)
    • Bridge
  • Lambda Storage Services
    • For Developers
  • Ecosystem
    • NFTs
    • AI Agents
    • LWS Storage Service
    • LDA Permanent DA Solution
Powered by GitBook
On this page
  • For Developers
  • #File Upload
  • #Submit onchain

Was this helpful?

  1. Lambda Storage Services

For Developers

PreviousLambda Storage ServicesNextNFTs

Last updated 1 year ago

Was this helpful?

For Developers

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

File Upload

This is a simple 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); });

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})

Submit onchain

Installation

Submit

Get file size

#
demo (opens new window)
#
#
#
#
#
#
#