1.1.4 • Published 1 year ago

gridfile v1.1.4

Weekly downloads
5
License
MIT
Repository
github
Last release
1 year ago

npm NPM npm Coverage Status Sponsor

GridFile - Mongoose Schema for MongoDB GridFS

GridFile is a reusable Mongoose schema for MongoDB GridFS. No separate database setup is needed as it uses the Mongoose connection for interacting with GridFS.

Installation

npm install gridfile

Usage

  • Import the schema
const schema = require('gridfile')
  • Create a Mongoose model from the schema
const GridFile = mongoose.model('GridFile', schema)
  • Upload a file
const fileStream = fs.createReadStream('/path/to/file.ext')

const gridFile = new GridFile()
gridFile.filename = 'file.ext'
await gridFile.upload(fileStream)
  • Download a file
const fileStream = fs.createWriteStream('/path/to/file.ext')
const gridFile = GridFile.findById('id')

await gridFile.download(fileStream)

Examples

Documentation

Documentation is available at API.md

Fixes & Improvements

Head over to the issues tab at github.com to report a bug or suggest an improvement. Feel free to contribute to the code or documentation by creating a pull request.

Sponsor / Support

If you find the project interesting or helpful, please consider sponsoring or supporting it at github.com.

1.1.4

1 year ago

1.1.3

2 years ago

1.1.2

2 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

4 years ago

1.0.0

4 years ago