Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gridfs-form

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gridfs-form

Multipart form binding storing files in gridfs.

  • 0.0.5
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
9
increased by350%
Maintainers
1
Weekly downloads
 
Created
Source

Introduction

Module aims to provide easy way to bind multipart forms using MongoDB GridFS feature for storing uploaded files. It does not write any temporary files, piping uploaded parts directly into gridfs instead (using gridfs-stream).

Implementation

For multipart request parsing it has a busboy-based implementation. Other implementations are welcome.

Usage

The module exports:

  • BusboyParser - busboy-based parser implementation
  • Form - Form binding implementation

A basic scenario

For the details, see tests.

// connection is a mongo connection, driver is the mongoose module
var Grid = require('gridfs-stream');
var GridfsForm = require('gridfs-form');
var Parser = GridfsForm.BusboyParser;
var Form = GridfsForm.Form;

var grid = new Grid(connection.db, driver.mongo)

// app is an express instance

app.get('/upload', function(req, res){
    var form = new Form(new Parser(), grid);
    form.bind(req, function(err, bind){
        if (err) {
            return res.status(500).send(err);
        }
        res.status(200).json(bind);    
    });
});  

Keywords

FAQs

Package last updated on 29 Oct 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc