0.1.1 • Published 7 years ago

@filestore/disk v0.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
7 years ago

FileStore - Disk

Store and retreive files to disk.

Installation

npm install --save @filestore/disk

Usage

const Disk = require('@filestore/disk')
const fs = require('fs')

const filestore = new Disk({ path: 'uploads' })
const file = fs.createReadStream('my-file.txt')

filestore.put('my-file.txt', file).then(() => {
  // "my-file.txt" is now copied to the directory "uploads"
})

API

The API is meant to be interchangeable with any other @filestore/... module.

new Disk(options)

  • options.path - Path to the directory to store files in
  • options.prefix - Prefix that will be prepended to each filename (e.g. "disk-")

Instantiates a new Disk FileStore class.

.put(id: string, data: Input[, options: object]) => Promise<void>

Save a file to disk.

data can be a ReadableStream, Buffer, string, Iterable<Buffer|string> or Promise.

.get(id: string) => ReadableStream

Fetch a file from disk.

.has(id: string) => Promise<boolean>

Check if a file exists on disk.

0.1.1

7 years ago

0.1.0

7 years ago