@filen/sdk

中文文档
0.4.2发布于 2026/07/11AGPLv3TypeScriptCommonJS近 30 天下载 2373

Filen SDK

原始使用文档
文档目录3 节
  1. Filen SDK
  2. Installation
  3. License

Filen SDK

SDK to interact with Filen for Node.JS, Browsers and React Native.

Explore the docs »

Contributors Forks Stargazers Issues License

Installation

  1. Install using NPM
npm install @filen/sdk@latest
  1. Initialize the SDK.
import { FilenSDK } from "@filen/sdk"
import path from "path"
import os from "os"

type FilenSDKConfig = {
    email?: string
    password?: string
    twoFactorCode?: string
    masterKeys?: string[]
    apiKey?: string
    publicKey?: string
    privateKey?: string
    authVersion?: AuthVersion
    baseFolderUUID?: string
    userId?: number
    metadataCache?: boolean // Cache decrypted metadata in memory. Recommended.
    tmpPath?: string // Temporary local path used to store metadata and chunks. Only available in Node.JS.,
    connectToSocket?: boolean // Recommended if you are using the virtual FS class. Keeps the internal item tree up to date with remote changes.
}

// You can either directly supply all needed config parameters to the constructor or call the .login() function to fetch them using your login information.
const filen = new FilenSDK({
    metadataCache: true,
    connectToSocket: true,
    tmpPath: path.join(os.tmpdir(), "filen-sdk")
})

await filen.login({
    email: "[email protected]",
    password: "supersecret123",
    twoFactorCode: "123456"
})
  1. Interact with the cloud
// Create a directory
await filen.fs().mkdir({
    path: "/Pictures"
})

// Upload a file
await filen.fs().upload({
    path: "/Pictures",
    source: "/Local/path/to/a/file.jpg"
})

// Read contents of the directory
const content: string[] = await filen.fs().readdir({
    path: "/Pictures"
})

// Stat a file
const stats: FSStats = await filen.fs().stat({
    path: "/Pictures/file.jpg"
})

// Download a file
await filen.fs().download({
    path: "/Pictures/file.jpg",
    destination: "/Local/path/to/a/file.jpg"
})

// Read a file
const content: Buffer = await filen.fs().readFile({
    path: "/Pictures/file.jpg"
})

// Write to a path
await filen.fs().writeFile({
    path: "/text.txt",
    content: Buffer.from("foobar", "utf-8")
})

License

Distributed under the AGPL-3.0 License. See LICENSE for more information.

版本与发布记录

@filen/sdk 共发布 208 个版本,首次发布于 2024/02/23;过去 12 个月发布了 2 个版本。

版本发布日期距今
0.4.2latest2026/07/114 个月前
0.4.12026/06/294 个月前
0.3.122025/10/091.1 年前
0.3.112025/08/211.2 年前
0.3.102025/08/051.3 年前
0.3.92025/08/041.3 年前

其他发布通道:beta → 0.3.1。

关于 @filen/sdk 的常见问题

@filen/sdk 是什么?

Filen SDK

如何安装 @filen/sdk?

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

@filen/sdk 支持 TypeScript 吗?

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

@filen/sdk 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

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

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

@filen/sdk 可以商用吗?

@filen/sdk 使用 AGPLv3 许可。声明的许可为 AGPLv3,请阅读许可原文确认使用条件。以上为概括,不构成法律意见,请以许可原文为准。

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

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

@filen/sdk 还在维护吗?

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