@filebase/sdk

中文文档
1.0.6发布于 2024/09/21MITTypeScriptESM + CJS近 30 天下载 5864

SDK for Interacting with Filebase Services [S3(Buckets, Objects), IPFS(Gateways, Pins) IPNS(Names)]

原始使用文档
文档目录4 节
  1. About
  2. JS Client
  3. Getting started
  4. Testing

• Filebase SDK •

Developer Friendly [ IPFS | IPNS | S3 ]

About

The Filebase SDK provides a hybrid data management solution, blending S3-compatible cloud storage with IPFS (InterPlanetary File System) pinning services. It features robust S3 bucket management, object handling for uploads and downloads, and seamless integration with IPFS and IPNS (InterPlanetary Naming System) for decentralized storage operations. The SDK supports advanced data tasks like compiling files into CAR (Content Addressable aRchive) formats and ensures secure transactions through strong authentication. Designed for varied applications, the Filebase SDK is ideal for scenarios demanding the dependability of cloud storage combined with the advantages of decentralized, peer-to-peer storage, catering to diverse needs such as content distribution, data backup, and archival. Developing InterPlanetary Applications has never been easier.

JS Client

Install the package using npm

npm install @filebase/sdk

or yarn:

yarn add @filebase/sdk

Getting started

The snippet below shows how to create a new bucket with BucketManager, upload a new object to IPFS with ObjectManager, publish the object to IPNS with NameManager, delete the object with ObjectManager and finally delete the bucket with BucketManager.

To use the library in your project, use npm or yarn to install the @filebase/sdk module. Requires node.js 16+.

node.js

// Import Classes
import {
  BucketManager, 
  ObjectManager, 
  NameManager, 
  GatewayManager, 
  PinManager
} from '@filebase/sdk'

// Initialize BucketManager
const bucketManager = new BucketManager(S3_KEY, S3_SECRET);
// Create bucket
const bucketName = `create-bucket-[random string]`;
await bucketManager.create(bucketName);

// Initialize ObjectManager
const objectManager = new ObjectManager(S3_KEY, S3_SECRET, {
  bucket: bucketName
});
// Upload Object
const objectName = `new-object`;
const uploadedObject = await objectManager.upload(objectName, body);
// Download Object
await uploadedObject.download();
// Copy Object to a New Bucket
const bucketCopyDestinationName = `copy-dest-bucket`
await bucketManager.create(bucketCopyDestinationName);
await objectManager.copy(`new-object`, bucketCopyDestinationName);

// Initialize NameManager
const nameManager = new NameManager(S3_KEY, S3_SECRET);
// Create New IPNS Name with Broadcast Disabled
const ipnsLabel = `myFirstIpnsKey`;
const ipnsName = await nameManager.create(ipnsLabel, uploadedObject.cid, {
  enabled: true
});

// Initialize GatewayManager
const gatewayManager = new GatewayManager(S3_KEY, S3_SECRET);
// Create New Gateway
const gatewayName = "myRandomGatewayName";
const myGateway = await gatewayManager.create(gatewayName);

// Initialize PinManager
const pinManager = new PinManager(S3_KEY, S3_SECRET, {
  bucket: bucketName,
  gateway: {
    endpoint: "https://myRandomGatewayName.myfilebase.com"
  }
});
// Create New Pin with Metadata
const myNewPin = await pinManager.create("my-pin", "QmTJkc7crTuPG7xRmCQSz1yioBpCW3juFBtJPXhQfdCqGF", {
  "application": "my-custom-app-on-filebase"
});

Full API reference doc for the JS client are available at https://filebase.github.io/filebase-sdk

Testing

Test are found in the test directory and are built to be run with the Node.js v20+ test runner.

版本与发布记录

@filebase/sdk 共发布 7 个版本,首次发布于 2023/12/23;过去 12 个月发布了 0 个版本。

版本发布日期距今
1.0.6latest2024/09/212 年前
1.0.52024/09/172 年前
1.0.42024/03/192 年前
1.0.32024/02/082 年前
1.0.22024/01/032 年前
1.0.12023/12/232 年前

关于 @filebase/sdk 的常见问题

@filebase/sdk 是什么?

SDK for Interacting with Filebase Services [S3(Buckets, Objects), IPFS(Gateways, Pins) IPNS(Names)]

如何安装 @filebase/sdk?

在项目目录运行 npm install @filebase/sdk,或使用 pnpm add / yarn add / bun add。

@filebase/sdk 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@filebase/sdk 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@filebase/sdk 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=16.0.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@filebase/sdk 可以商用吗?

@filebase/sdk 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@filebase/sdk 的下载量有多少?

根据 npm 官方下载统计,@filebase/sdk 在 2026/10/15 – 2026/11/13 这 30 天内被下载 5,864 次,日均约 195 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@filebase/sdk 还在维护吗?

最新版本 1.0.6 发布于 2024/09/21(2 年前);至今共发布 7 个版本,其中过去 12 个月发布了 0 个;首次发布于 2023/12/23。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。