Non Programming Manager

    @filestore/disk
    TypeScript icon, indicating that this package has built-in type declarations

    0.1.1 • Public • Published

    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.

    Keywords

    none

    Install

    npm i @filestore/disk

    DownloadsWeekly Downloads

    0

    Version

    0.1.1

    License

    MIT

    Last publish

    Collaborators

    • cstruct
    • linusu