0.1.63 • Published 6 days ago

@filen/sdk v0.1.63

Weekly downloads
-
License
AGPLv3
Repository
github
Last release
6 days ago

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,
	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.

0.1.63

6 days ago

0.1.60

7 days ago

0.1.61

7 days ago

0.1.62

7 days ago

0.1.59

8 days ago

0.1.55

9 days ago

0.1.56

9 days ago

0.1.57

9 days ago

0.1.58

9 days ago

0.1.52

12 days ago

0.1.53

12 days ago

0.1.54

12 days ago

0.1.50

12 days ago

0.1.51

12 days ago

0.1.48

22 days ago

0.1.47

1 month ago

0.1.46

1 month ago

0.1.43

1 month ago

0.1.44

1 month ago

0.1.45

1 month ago

0.1.37

1 month ago

0.1.41

1 month ago

0.1.42

1 month ago

0.1.40

1 month ago

0.1.38

1 month ago

0.1.39

1 month ago

0.1.33

1 month ago

0.1.34

1 month ago

0.1.35

1 month ago

0.1.36

1 month ago

0.1.30

2 months ago

0.1.31

2 months ago

0.1.32

2 months ago

0.1.28

2 months ago

0.1.27

2 months ago

0.1.26

2 months ago

0.1.22

2 months ago

0.1.23

2 months ago

0.1.24

2 months ago

0.1.25

2 months ago

0.1.20

2 months ago

0.1.17

2 months ago

0.1.18

2 months ago

0.1.19

2 months ago

0.1.15

2 months ago

0.1.16

2 months ago

0.1.13

2 months ago

0.1.14

2 months ago

0.1.10

2 months ago

0.1.11

2 months ago

0.1.12

2 months ago

0.1.2

2 months ago

0.1.8

2 months ago

0.1.7

2 months ago

0.1.9

2 months ago

0.1.4

2 months ago

0.1.3

2 months ago

0.1.6

2 months ago

0.1.1

2 months ago

0.1.0

2 months ago