Registry / storage / flydrive

flydrive

JSON →
library2.1.0jsnpmunverified

FlyDrive is a multi-driver file storage library for Node.js that provides a unified API to interact with local filesystem and cloud storage providers including S3, GCS, and R2. The current stable version is 2.1.0, released with a focus on modern ESM-only usage and requiring Node.js >=24. It ships full TypeScript definitions and uses a driver-based architecture. Unlike generic SDK wrappers, FlyDrive offers an abstraction layer that allows swapping backends without changing application code. Packages are released on npm as needed, with a stable release cadence.

npm install flydrive
INSTALL
IMPORT
SIG · FLYDRIVE
F
flydrive
storagejavascriptv2.1.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

FlyDrive
import { FlyDrive } from 'flydrive'
const FlyDrive = require('flydrive')
FlyDrive is ESM-only since v2. CommonJS require will fail.
fsDriver
import { fsDriver } from 'flydrive/drivers/fs'
import { fsDriver } from 'flydrive'
Drivers are exported from subpaths, not the main entry.
s3Driver
import { s3Driver } from 'flydrive/drivers/s3'
import { s3Driver } from 'flydrive'
S3 driver must be imported from the dedicated subpath.
gcsDriver
import { gcsDriver } from 'flydrive/drivers/gcs'
import { gcsDriver } from 'flydrive'
GCS driver is exported from the gcs subpath.

Shows how to instantiate filesystem, S3, and GCS drivers and perform basic file operations like put, get, getUrl, getSignedUrl, and exists.

import { FlyDrive } from 'flydrive' import { fsDriver } from 'flydrive/drivers/fs' import { s3Driver } from 'flydrive/drivers/s3' import { GcsDriver } from 'flydrive/drivers/gcs' // Filesystem driver const fs = new FlyDrive({ driver: fsDriver({ location: './storage', visibility: 'private', appUrl: 'http://localhost:3333' }) }) await fs.put('hello.txt', 'Hello world') const content = await fs.get('hello.txt') console.log(content) // S3 driver const s3 = new FlyDrive({ driver: s3Driver({ credentials: { accessKeyId: process.env.AWS_ACCESS_KEY_ID ?? '', secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY ?? '' }, region: 'us-east-1', bucket: 'my-bucket' }) }) await s3.put('file.txt', 'Buffer or string', { contentType: 'text/plain' }) const url = await s3.getUrl('file.txt') const signedUrl = await s3.getSignedUrl('file.txt', { expiresIn: '30mins' }) console.log({ url, signedUrl }) // GCS driver const gcs = new FlyDrive({ driver: new GcsDriver({ keyFilename: '/path/to/key.json', bucket: 'my-gcs-bucket' }) }) await gcs.put('data.json', JSON.stringify({ key: 'value' })) const exists = await gcs.exists('data.json') console.log(exists)
Debug
Known issues
breakingFlyDrive v2 is ESM-only and drops CommonJS support. Requires Node.js >=24.
fix
Update to Node.js 24+ and use ESM imports. Do not use require().
affects: >=2.0.0
deprecatedThe `gcsDriver` function is deprecated in favor of the `GcsDriver` class.
fix
Replace `gcsDriver(...)` with `new GcsDriver(...)`.
affects: >=2.1.0
gotchaDrivers (fsDriver, s3Driver) are not exported from the main package path. They must be imported from subpaths (e.g., 'flydrive/drivers/fs').
fix
Import from the correct subpath: 'flydrive/drivers/fs' or 'flydrive/drivers/s3'.
affects: >=2.0.0
gotchaS3 driver requires both @aws-sdk/client-s3 and @aws-sdk/s3-request-presigner as peer dependencies.
fix
Install both peer dependencies: npm install @aws-sdk/client-s3 @aws-sdk/s3-request-presigner
affects: >=2.0.0
gotchaThe `visibility` configuration for the filesystem driver only affects URLs generated by `getUrl`; actual filesystem permissions are not managed.
fix
Use `visibility: 'public'` to generate public URLs; adjust filesystem permissions separately if needed.
affects: >=2.0.0
Errors
Common errors & fixes
Error [ERR_REQUIRE_ESM]: require() of ES Module .../node_modules/flydrive/build/index.js from ... not supported. Instead change the require of index.js to a dynamic import() which is available in all CommonJS modules.
Using require() on an ESM-only package.
fix
Replace require() with import or set type: module in package.json and use ESM syntax.
Module not found: Error: Can't resolve 'flydrive/drivers/fs'
Attempting to import a driver from the wrong path (e.g., 'flydrive').
fix
Use the correct subpath: 'flydrive/drivers/fs', 'flydrive/drivers/s3', or 'flydrive/drivers/gcs'.
ERR_PACKAGE_PATH_NOT_EXPORTED: Package subpath './dist/drivers/fs' is not defined by 'exports' in .../node_modules/flydrive/package.json
Using an old import path with 'dist/' subdirectory.
fix
Remove 'dist/' from path: import from 'flydrive/drivers/fs'.
Upgrade
Version history
2.1.0latest on npm
Audit
Dependencies
@aws-sdk/client-s3optionalRequired for S3 driver to interact with AWS S3 API
@aws-sdk/s3-request-presigneroptionalRequired for S3 signed URL generation
@google-cloud/storageoptionalRequired for GCS driver to interact with Google Cloud Storage API
Agent activity
30 hits · last 30 days
node
26
OpenAI (training)
1
Resources
flydrive — npm install flydrive · libregistry