# For Developers

### For Developers <a href="#for-developers" id="for-developers"></a>

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

### [#](https://docs.lambda.im/storage/developers.html#file-upload)File Upload <a href="#file-upload" id="file-upload"></a>

This is a simple [demo (opens new window)](https://github.com/LambdaIM/upload_demo)demonstrates how to upload file or folder

#### [#](https://docs.lambda.im/storage/developers.html#installation)Installation <a href="#installation" id="installation"></a>

<mark style="background-color:purple;">yarn install</mark>

#### [#](https://docs.lambda.im/storage/developers.html#run)Run <a href="#run" id="run"></a>

//upload file&#x20;

<mark style="background-color:purple;">yarn upload-file</mark>

//upload folder&#x20;

<mark style="background-color:purple;">yarn upload-folder</mark>

#### [#](https://docs.lambda.im/storage/developers.html#integration)Integration <a href="#integration" id="integration"></a>

1. How to upload file

<mark style="background-color:purple;">const LambdaStorage = require('./LambdaStorage');</mark>

<mark style="background-color:purple;">const filePath = './data/file-to-upload.png';</mark>

<mark style="background-color:purple;">const lambdaStorage = new LambdaStorage();</mark>

<mark style="background-color:purple;">console.log(</mark><mark style="background-color:purple;">`Uploading ${filePath}...`</mark><mark style="background-color:purple;">);</mark>

<mark style="background-color:purple;">lambdaStorage.upload(filePath).then((response) => { console.log(response); }).catch((error) => { console.log(error); });</mark>

2. How to upload folder

<mark style="background-color:purple;">const LambdaStorage = require('./LambdaStorage');</mark>

<mark style="background-color:purple;">const folderPath = './data/folder-to-upload/';</mark>

<mark style="background-color:purple;">const lambdaStorage = new LambdaStorage();</mark>

<mark style="background-color:purple;">console.log(</mark><mark style="background-color:purple;">`Uploading folder ${folderPath}...`</mark><mark style="background-color:purple;">);</mark>

<mark style="background-color:purple;">lambdaStorage.upload(folderPath,true).then((response) => { console.log(response); }).catch((error) => { console.log(error); });</mark>

### [#](https://docs.lambda.im/storage/developers.html#submit-onchain)Submit onchain <a href="#submit-onchain" id="submit-onchain"></a>

#### [#](https://docs.lambda.im/storage/developers.html#installation-2)Installation <a href="#installation-2" id="installation-2"></a>

<mark style="background-color:purple;">npm i lambdaupload</mark>

#### [#](https://docs.lambda.im/storage/developers.html#submit)Submit <a href="#submit" id="submit"></a>

You need to provide account address, file name, cid and filesize

<mark style="background-color:purple;">import { uploadFiles } from 'lambdaupload'</mark>

<mark style="background-color:purple;">await uploadFiles({ provider, account, name, cid, filesize })</mark>

You need to submit the actual file/folder size, otherwise storage node will refuse to provide data availability for mismatch size.

#### [#](https://docs.lambda.im/storage/developers.html#get-file-size)Get file size <a href="#get-file-size" id="get-file-size"></a>

<mark style="background-color:purple;">import { getFileSize } from 'lambdaupload'</mark>

<mark style="background-color:purple;">await getFileSize({ provider, cid})</mark>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.lambda.im/faq/for-developers.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
