gridform
======================
Formidable streams uploads to the file system by default. If you're using GridFS to store files you'll then need to turn around and copy them off of the file system. Using gridform
removes this burden.
Example:
var mongo = var gridform = ; // assuming you've already created a db instance and opened itgridformdb = db;gridformmongo = mongo; // in your http servervar app = http;
install
npm install gridform
exports
The module exports a function which takes an options object.
var gridform = ;var options = db: db mongo: mongo filename: fn ;var form = ;
Available options:
- db: an open node-mongodb-native db instance
- mongo: the node-mongodb-native driver you are using
- filename: function
The optional filename
function is passed the file.name
before streaming to MongoDB providing an opportunity to return a customized filename with a prefix etc.
db
and mongo
are required unless you've specified them on gridform
itself.
var gridform = ;gridformdb = db;gridformmongo = mongo;var form = ; // all good
The gridform function returns an instance of formidable.IncomingForm
so you can process uploads without changing any code.
gridfs-stream
This module utilizes the gridfs-stream module which is exposed as require('gridform').gridfsStream
.
tests
Run the tests with make test
.