@filen/sdk
TypeScript icon, indicating that this package has built-in type declarations

0.1.167 • Public • Published

Filen SDK

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

Explore the docs »

Contributors Forks Stargazers Issues License

Attention

The SDK is still a work in progress. DO NOT USE IT IN PRODUCTION YET. Class names, function names, types, definitions, constants etc. are subject to change until we release a fully tested and stable version.

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: "your@email.com",
	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.

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
0.1.167290latest

Version History

VersionDownloads (Last 7 Days)Published
0.1.167290
0.1.1663
0.1.1659
0.1.1641
0.1.1632
0.1.1620
0.1.1610
0.1.1600
0.1.1590
0.1.1580
0.1.1570
0.1.1560
0.1.1550
0.1.1540
0.1.1530
0.1.1520
0.1.1510
0.1.1500
0.1.1490
0.1.1480
0.1.1470
0.1.1460
0.1.1450
0.1.1440
0.1.1430
0.1.1420
0.1.1410
0.1.1400
0.1.1390
0.1.1380
0.1.1370
0.1.1360
0.1.1350
0.1.1341
0.1.1330
0.1.1320
0.1.1310
0.1.1300
0.1.1290
0.1.1280
0.1.1270
0.1.1260
0.1.1250
0.1.1240
0.1.1230
0.1.1220
0.1.1200
0.1.1190
0.1.1180
0.1.1170
0.1.1160
0.1.1150
0.1.1140
0.1.1130
0.1.1110
0.1.1100
0.1.1090
0.1.1080
0.1.1070
0.1.1060
0.1.1050
0.1.1040
0.1.1020
0.1.1010
0.1.1000
0.1.990
0.1.980
0.1.970
0.1.960
0.1.950
0.1.940
0.1.930
0.1.920
0.1.910
0.1.900
0.1.890
0.1.880
0.1.860
0.1.850
0.1.840
0.1.830
0.1.820
0.1.810
0.1.800
0.1.790
0.1.780
0.1.770
0.1.760
0.1.750
0.1.740
0.1.730
0.1.720
0.1.710
0.1.700
0.1.690
0.1.680
0.1.670
0.1.660
0.1.650
0.1.640
0.1.630
0.1.620
0.1.610
0.1.600
0.1.590
0.1.580
0.1.570
0.1.560
0.1.550
0.1.540
0.1.530
0.1.520
0.1.510
0.1.500
0.1.480
0.1.470
0.1.460
0.1.450
0.1.440
0.1.430
0.1.420
0.1.410
0.1.400
0.1.390
0.1.380
0.1.370
0.1.360
0.1.350
0.1.340
0.1.330
0.1.320
0.1.310
0.1.300
0.1.280
0.1.270
0.1.260
0.1.250
0.1.240
0.1.230
0.1.220
0.1.200
0.1.190
0.1.180
0.1.170
0.1.160
0.1.150
0.1.140
0.1.130
0.1.120
0.1.110
0.1.100
0.1.90
0.1.80
0.1.70
0.1.60
0.1.40
0.1.30
0.1.20
0.1.10
0.1.00

Package Sidebar

Install

npm i @filen/sdk

Weekly Downloads

306

Version

0.1.167

License

AGPLv3

Unpacked Size

2.54 MB

Total Files

884

Last publish

Collaborators

  • filen