Skip to content

πŸ“ Unified Node.js fs-like API for cloud storage services

License

Notifications You must be signed in to change notification settings

AnandChowdhary/unfs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

24 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“ Unfs

Node.js API like fs, but for cloud storage services. If you're used to doing fs.writeFile(), this should be easy.

Node CI Checks Coverage npm version Types Dependencies Dev dependencies Peer dependencies Install size License

☁️ Services

  • AWS S3
  • Azure Storage
  • Google Cloud Storage
  • Firebase Cloud Storage
  • Memory file system
  • In memory (for testing only)

πŸ’‘ Usage

Install the package from npm:

npm install unfs

With TypeScript or ES6 async modules:

import Unfs from "unfs";
const fs = new Unfs({
  service: "s3",
  bucket: "s3-bucket-name",
  auth: {}
}));

const url = await fs.writeFile("message.txt", "Hello, world");
console.log("url", url);

With Node.js using the Promise API:

const Unfs = require("unfs");
const fs = new Unfs({
  service: "s3",
  bucket: "s3-bucket-name",
  auth: {}
});

fs.writeFile("message.txt", "Hello, world")
  .then(url => console.log("url", url))
  .catch(error => console.error("error", error));

βš’ Configuration

General

The following constructor properties can be used in all services:

const fs = new Unfs({
  service: "your-service-here", // Select a service from below
  prefix: "prefix_", // Add prefix to file name before saving
  suffix: "_suffix", // Add Suffix to file name before saving
  softDelete: true // Set to `true` to rename instead of deleting files,
  deletePrefix: "deleted_" // Use with `softDelete` as file prexix
}));

Memory

Note: You should only use the Memory service in development, since you'll end up using lots of RAM when storing binary files in memory.

const fs = new Unfs({
  service: "memory"
}));

πŸ“„ License

MIT Β© Anand Chowdhary

About

πŸ“ Unified Node.js fs-like API for cloud storage services

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages