gridfs-form

2019-06-13 admin

gridfs-form是什么

什么是gridfs-form,Multipart form binding storing files in gridfs.

gridfs-form使用教程帮助文档

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
Grid = require 'gridfs-stream'
{BusboyParser, Form} = require 'gridfs-form'

grid = new Grid connection.db, driver.mongo

// app is an express instance

app.post '/upload', (req, res) ->
    form = new Form new BusboyParser(), grid
    form.bind req, (err, bind) ->
        return res.status(500).send(err) if err
        res.status(200).json(bind);

本站文章除注明转载外,均为本站原创或编译。欢迎任何形式的转载,但请务必注明出处。

转载请注明:文章转载自 JavaScript中文网 [https://www.javascriptcn.com]

本文地址:https://www.javascriptcn.com/read-67217.html

文章标题:gridfs-form

回到顶部