4EVERLAND Documents
HomeTwitterDiscordBlogs
  • Welcome to 4EVERLAND
  • Get started
    • Our Features
    • Quick Start Guide
      • Registration
      • Login options
        • MetaMask
        • OKX Wallet
        • Binance Web3 Wallet
        • Bitget Wallet
        • Phantom
        • Petra
        • Lilico
      • Usage Introduction
      • Dashboard stats
      • Account
        • Linking Your EVM Wallet to 4EVERLAND Account
        • Balance Alert
    • Billing and Pricing
      • What is LAND?
      • How to Obtain LAND?
      • Pricing Model
      • Q&As
    • Tokenomics
  • HOSITNG
    • What is Hosting?
      • IPFS Hosting
      • Arweave Hosting
        • Auto-Generation of Manifest
      • Internet Computer Hosting
      • Greenfield Hosting
    • Guides
      • Creating a Deployment
        • With Git
        • With IPFS Hash
        • With a Template
      • Site Deployment
      • Domain Management
        • DNS Setup Guide
        • ENS Setup Guide
        • SNS Setup Guide
          • The gateway: 4sol.xyz
        • SPACE ID Setup Guide
      • Project Setting
        • Git
      • Troubleshooting
      • Common Frameworks
    • Hosting Templates Centre
      • Templates Configuration File
    • Quick Addition
      • Implement Github 4EVER Pin
      • Github Deployment Button
    • Hosting API
      • Create Project API
      • Deploy Project API
      • Get Task Info API
      • IPNS Deployment Update API
    • Hosting CLI
  • Storage
    • Bucket
      • IPFS Bucket
        • Get Root CID - Snapshots
      • Arweave Bucket
        • Path Manifests
          • Instructions for Building Manifest
          • Auto-Generation of Manifest
        • Arweave Tags
        • Unleash Arweave
      • Guides
      • Bucket API - S3 Compatible
        • Coding Examples
          • AWS SDK - Go (Golang)
          • AWS SDK - Java
          • AWS SDK - JavaScript
          • AWS SDK - .NET
          • AWS SDK - PHP
          • AWS SDK - Python
          • AWS SDK - Ruby
        • S3 Tags Instructions
      • 4EVER Security Token Service API
      • Bucket Tools
      • Bucket Gateway Optimizer
    • 4EVER Pin
      • Guides
      • Pinning Services API
      • IPFS Migrator
    • Storage SDK
  • Gateways
    • IPFS Gateway
    • IC Gateway
    • Arweave Gateway
    • Dedicated Gateways
      • Gateway Access Controls
      • Video Streaming
      • IPFS Image Optimizer
    • IPNS Manager
      • IPNS Manager API
  • RPC
    • Guides
    • API Keys
    • JSON Web Token (JWT)
    • What's CUs/CUPS
    • WebSockets
    • Archive Node
    • Debug API
    • Chains RPC
      • BSC / opBNB
      • Ethereum
      • Optimism
      • Polygon
      • Taiko
  • AI
    • AI RPC
      • Quick Start
      • Models
      • API Keys
      • Requests & Responses
      • Parameters
    • 4EVER Chat
  • RaaS - Beta
    • What's Rollups?
    • 4EVER Rollup Stack
  • DePIN
    • 4EVER Network
    • Storage Nodes
  • More
    • Use Cases
      • Livepeer
      • Lens Protocol
      • Optopia.ai
      • Linear Finance
      • Snapshot
      • Tape
      • Taiko
      • Hey.xyz
      • SyncSwap
    • Community
    • Tutorials
    • Security
    • 4EVERLAND FAQ
Powered by GitBook
On this page
  • Introduction
  • Get started
  • AuthClient
  • getSignText(address: string):string
  • verifySign(address: string, signature: string):ValidSignResult
  • BucketClient
  • upload(params: ClientUploadParams) :UploadResult
  • PinClient
  • addPin(addPin: AddPinParams):PinInfo
  • getPin(requestid: string):PinInfo
  • listPin(params: PinParams):ListPin
  • replacePin(requestid: string, addPin: AddPinParams):PinInfo
  1. Storage

Storage SDK

Last updated 10 months ago

Introduction

The 4EVER Pin SDK provides a set of tools for directly uploading files to a specified 4EVER Pin account list. It includes three classes: AuthClient, BucketClient, and PinClient. Developers can refer to this documentation to combine and utilize these three classes to achieve file uploading functionality to 4EVER Pin. They can also refer to the for guidance.

Get started

Install @4everland/upload-pin

npm i @4everland/upload-pin
yarn add @4everland/upload-pin

AuthClient

To obtain the relevant permission information for the file upload functionality, developers would need to utilize the methods within the AuthClient class, which include getSignText and verifySign. These methods are essential for acquiring the necessary permissions and verifying the authentication of the file upload process.

Parameters

url: string Required parameter

The available Auth API to be filled in is:

https://auth.api.4everland.org

Examples

// New AuthClint instance
import { AuthClient } from '@4everland/upload-pin'

const url = '' 
const authclient = new AuthClient(url)

getSignText(address: string):string

The getSignText method is used to obtain plaintext for wallet signatures.

Parameters

address: stringRequired parameter: the wallet address to be signed.

Returns

signText: stringThe plaintext information for the signature.

Examples

let address = '' // metamask address
const signMessage = await authclient.getSignText(address)

verifySign(address: string, signature: string):ValidSignResult

The verifySign method is used to verify the validity of the signature. Upon successful verification, the relevant permission information required for file upload can be obtained.

Parameters

address: stringRequired parameter: the address to be validated for the signature. signature: stringRequired parameter: the signature to be verified.

Returns

verifySign returns a ValidSignResult object with seven properties:

  • expiration: number: The expiration time of the signature (2 hours)

  • accessBucket: string: The temporary Bucket used for file upload

  • folderPath: string: The folder path within the temporary Bucket used for file upload

  • token: string: Token for invoking 4EVER Pin

  • accessKeyId: string: The KeyID for the temporary S3 Bucket

  • secretAccessKey: string: The secret key for the temporary S3 Bucket

  • sessionToken: string: The STS Token for the temporary S3 Bucket

Examples

// Verification signature
// if expiration expired, you need Verification signature again
const { expiration } = await client.verifySign(address, signature)

BucketClient

The BucketClient class contains an upload method used for uploading files to a specified Bucket and obtaining the file CID.

Parameters

params:BucketClientParamsThe required properties for this object include:

  • accessKeyId:string: Access key ID for the Bucket

  • secretAccessKey: string: Private key for the Bucket

  • sessionToken:string: Temporary token, valid for 24 hours

  • endpoint:string: S3 endpoint, currently available at 'https://endpoint.4everland.co'

Examples

//New BucketClint instance
import { BucketClient } from '@4everland/upload-pin'

const {params}= {
  accessKeyId: ''
  secretAccessKey: ''
  sessionToken: ''
  endpoint: 'https://endpoint.4everland.co'
}
const bucketclient = new BucketClient(params)

upload(params: ClientUploadParams) :UploadResult

The upload method is used for uploading files to the specified Bucket.

Parameters

params: ClientUploadParamsRequired parameters for this object include the following properties:

  • Key: string: File path (folderPath + '/' + file name, where folderPath is a parameter returned from verifySign)

  • Body: StreamingBlobPayloadInputType: File stream

  • ContentType?:string: File type

Returns

The upload method returns an UploadResult object with three properties:

  • abort: () => Promise<void>: Calling this function can terminate the file upload process.

  • done: () => Promise<{ cid: string }>: Calling this function after the file upload is complete will provide its CID (object).

  • progress: (cb?: (e: Progress) => void) => void: This callback function logs the file upload process steps in the console.

    - Uploaded portion: e.loaded - Total: e.total

Examples

const task = bucketclient.upload({
    Key: folderPath + '/'+ file.name,
    Body: file,
    ContentType: file.type
})

task.progress((e) => {
    console.log(e.loaded)
    console.log(e.total)
})

const { cid } = await task.done()

PinClient

Based on the Pinning Service API, the PinClient class includes three methods: addPin, getPin, and listPin. These methods enable the uploading of CIDs to 4EVER Pin and querying for relevant information.

Parameters

params:PinningClientParamsThe required properties for this object include the following:

  • baseURL:string: Pinning service endpoint. Currently available at 'https://api.4everland.dev'

  • accessToken: string: Access token for 4EVER Pin

Examples

//New BucketClint instance
import { PintClient } from '@4everland/upload-pin'

const {params}= {
  baseURL: 'https://api.4everland.dev'
  accessToken:''
}
const pinclient = new PinClient(params)

addPin(addPin: AddPinParams):PinInfo

Parameters

addPin: AddPinParams

export interface AddPinParams {
  cid: string
  name?: string
  origins?: string[]
  meta?: {
    [K in string]: string
  }

Returns

PinInfo

export interface PinInfo {
  requestid: string
  status: string
  created: string
  pin: {
    cid: string
    name?: string
    origins?: string[]
    meta?: {
      [K in string]: string
    }
  }
  delegates: string[]
  info?: {
    [K in string]: string
  }
}

Examples

const { requestid } = await pinclinet.addPin({
  cid
})

getPin(requestid: string):PinInfo

Parameters

requestid: stringsRequired parameter: the requestid from the response of the addPin method.

Returns

PinInfo

export interface PinInfo {
  requestid: string
  status: string
  created: string
  pin: {
    cid: string
    name?: string
    origins?: string[]
    meta?: {
      [K in string]: string
    }
  }
  delegates: string[]
  info?: {
    [K in string]: string
  }
}

Examples

await pinclinet.getPin(requestid)

listPin(params: PinParams):ListPin

Parameters

params: PinParams

export interface PinParams {
  cid?: string
  name?: string
  status?: string
  limit?: number
  before?: string
  after?: string
}

Returns

PinInfo

export interface ListPin {
  count: number
  results: PinInfo[]
}

Examples

await pinclinet.listPin()

replacePin(requestid: string, addPin: AddPinParams):PinInfo

Parameters

requestid: stringsRequired parameter: the requestid from the response of the addPin method.addPin: AddPinParams

export interface AddPinParams {
  cid: string
  name?: string
  origins?: string[]
  meta?: {
    [K in string]: string
  }

Returns

PinInfo

export interface ListPin {
  count: number
  results: PinInfo[]
}

Examples

await pinclinet.replacePin(requestid,addpinparams)

The addPin method is used to directly add a CID to 4EVER Pin. This method is part of the Pinning Service API, and the meaning of the request and response parameters can be found in the under the "Add pin object" section.

The getPin method is utilized to query the specified pinned file's information and status. This method is part of the Pinning Service API, hence, the meanings of its request and response parameters can be referenced in the under the "Get pin object" section.

The listPin method is used to query the specified pinned file's information and status. This method is part of the Pinning Service API, and its request and response parameters can be referenced in the under the "List pin object" section.

4EVER Pin SDK Demo
Pinning Service API documentation
Pinning Service API documentation
Pinning Service API documentation