# @flystorage/file-storage

> File-storage abstraction: multiple filesystems, one API.

Latest version **1.2.2** (published 2026-01-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install @flystorage/file-storage
pnpm add @flystorage/file-storage
yarn add @flystorage/file-storage
bun add @flystorage/file-storage
```

## Health

**Score 55/100 (C)** — status: stable.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 1.2.2 |
| Published | 2026-01-24 |
| First published | 2023-11-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 82.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 311 |
| Author | Frank de Jonge |
| Maintainers | frankdejonge |
| Keywords | fs, file, files, filesystem, filesystems, storage |

## Links

- npm: https://www.npmjs.com/package/@flystorage/file-storage
- Repository: https://github.com/duna-oss/flystorage
- Homepage: https://flystorage.dev/
- Issues: https://github.com/duna-oss/flystorage/issues
- npm.io page: https://npm.io/package/@flystorage/file-storage

## Alternatives

- [unionfs](https://npm.io/package/unionfs.md) — 2.2M weekly downloads
- [path-starts-with](https://npm.io/package/path-starts-with.md) — 35.9K weekly downloads
- [redzip](https://npm.io/package/redzip.md) — 1.2K weekly downloads
- [vscode-anymatch](https://npm.io/package/vscode-anymatch.md) — 848 weekly downloads
- [@ledgerhq/coin-filecoin](https://npm.io/package/@ledgerhq/coin-filecoin.md) — 793 weekly downloads

## Recent versions

- 1.2.2 (latest) — 2026-01-24
- 1.2.1 — 2025-11-29
- 1.2.0 — 2025-09-13
- 1.1.0 — 2025-05-13
- 1.0.1 — 2025-01-14
- 1.0.0 — 2024-12-12
- 0.1.7 — 2024-11-28
- 0.1.5 — 2024-09-15
- 0.1.4 — 2024-06-06
- 0.1.3 — 2024-06-06
- 0.1.2 — 2024-05-25
- 0.1.1 — 2024-02-25
- 0.1.0 — 2023-12-28
- 0.0.9 — 2023-12-11
- 0.0.8 — 2023-12-06
- … 7 more at https://npm.io/package/@flystorage/file-storage/versions

## README

<img src="https://raw.githubusercontent.com/duna-oss/flystorage/main/flystorage.svg" width="50px" height="50px" />

# Flystorage
Flystorage is a file storage abstraction for NodeJS and TypeScript. It is an 80/20 solution
that is built around a set of goals:

- Provide a straight-forward API that is easy to use.
- Allow application code to be unaware WHERE files are stored.
- Pragmatically smooth over underlying storage differences.
- Expose an async/await based API, promises all the way.
- Abstract over file permissions using "visibility".
- Actually tested using real integrations, _mocks are not welcome_.
- Stand on the shoulders of giants, use official vendor packages when possible.

### What is Flystorage NOT:
Flystorage is meant to be used in cases for generic file storage use-cases. It's not an API for
any  specific filesystem. It's a generalised solution and will not implement feature only
specific to one particular storage implementation. There will be use-cases that are not catered
to, simply because they cannot be abstracted over in a reasonable manner.

## Capabilities

- Write files using string | buffer | readable/stream
- Read files as stream, string, or Uint8Array
- List the contents of a directory/prefix, (shallow and deep).
- Metadata, such as; mime-type, last modified timestamp, and file size.
- Expose or calculate checksums for files.
- Delete files without failing when they don't exist.
- Set permissions using abstracted visibility
- Delete directories (and any files it contains)
- Generate public URLs.
- Generate temporary (signed) URLs.
- Secure direct uploads from the browser.
- Moving files
- Copying files


## Adapters
- [Local Filesystem](https://www.npmjs.com/package/@flystorage/local-fs)
- [AWS S3 (using the V3 SDK)](https://www.npmjs.com/package/@flystorage/aws-s3)
- [Azure Blob Storage](https://www.npmjs.com/package/@flystorage/azure-storage-blob)
- [Test implementation (in-memory)](https://www.npmjs.com/package/@flystorage/in-memory)
- [Google Cloud Storage](https://www.npmjs.com/package/@flystorage/google-cloud-storage)
- [Chaos adapter decorator](https://www.npmjs.com/package/@flystorage/chaos)

## Usage
Install the main package and any adapters you might need:

```bash
npm i -S @flystorage/file-storage

# for using AWS S3
npm i -S @flystorage/aws-s3

# for using the local filesystem
npm i -S @flystorage/local-fs
```

## Local Usage
```typescript
import {resolve} from 'node:path';
import {createReadStream} from 'node:fs';
import {FileStorage, Visibility} from '@flystorage/file-storage';
import {LocalStorageAdapter} from '@flystorage/local-fs';

/**
 * SETUP
 **/

const rootDirectory = resolve(process.cwd(), 'my-files');
const storage = new FileStorage(new LocalStorageAdapter(rootDirectory));

/**
 * USAGE
 **/

// Write using a string
await storage.write('write-from-a-string.txt', 'file contents');

// Write using a stream
const stream = createReadStream(resolve(process.cwd(), 'test-files/picture.png'));
await storage.write('picture.png', stream);

// Write with visibility (permissions).
await storage.write('public.txt', 'debug', {
    visibility: Visibility.PUBLIC, // mode: 0o644
});
await storage.write('private.txt', 'debug', {
    visibility: Visibility.PRIVATE, // mode: 0o600
});

// List directory contents
const contentsAsAsyncGenerator = storage.list('', {deep: true});

for await (const item of contentsAsAsyncGenerator) {
    console.log(item.path);

    if (item.isFile) {
        // do something with the file
    } else if (item.isDirectory) {
        // do something with the directory
    }
}

// Delete a file
await storage.deleteFile('some-file.txt');

// Delete a directory (with all contents)
await storage.deleteDirectory('some-directory');
```

## Author
Flystorage is built by the maintainer of [Flysystem](https://flysystem.thephpleague.com), a
filesystem abstraction for PHP. This brings along over
a decade of filesystem abstraction experience.

---
_Source: https://npm.io/package/@flystorage/file-storage · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
