All Projects → huangang → fastify-file-upload

huangang / fastify-file-upload

Licence: other
Fastify plugin for uploading files

Programming Languages

javascript
184084 projects - #8 most used programming language
typescript
32286 projects

Projects that are alternatives of or similar to fastify-file-upload

fastify-jwt-authz
Verify authenticated user scope
Stars: ✭ 14 (-79.41%)
Mutual labels:  fastify, fastifyjs-plugin
fastify-webpack-hmr
Webpack hot module reloading for Fastify
Stars: ✭ 29 (-57.35%)
Mutual labels:  fastify, fastify-plugin
fastify-csrf
A fastify csrf plugin.
Stars: ✭ 88 (+29.41%)
Mutual labels:  fastify, fastify-plugin
fastify-axios
Add axios http client to your fastify instance
Stars: ✭ 28 (-58.82%)
Mutual labels:  fastify, fastify-plugin
fastify-passport
Use passport strategies for authentication within a fastify application
Stars: ✭ 150 (+120.59%)
Mutual labels:  fastify, fastify-plugin
fastify-vite
This plugin lets you load a Vite client application and set it up for Server-Side Rendering (SSR) with Fastify.
Stars: ✭ 497 (+630.88%)
Mutual labels:  fastify, fastify-plugin
fastify-leveldb
Plugin to share a common LevelDB connection across Fastify.
Stars: ✭ 19 (-72.06%)
Mutual labels:  fastify, fastify-plugin
fastify-loader
The route loader for the cool kids!
Stars: ✭ 17 (-75%)
Mutual labels:  fastify, fastify-plugin
fastify-etag
Automatically generate etags for HTTP responses, for Fastify
Stars: ✭ 61 (-10.29%)
Mutual labels:  fastify, fastify-plugin
create-fastify-app
An utility that help you to generate or add plugin to your Fastify project
Stars: ✭ 53 (-22.06%)
Mutual labels:  fastify, fastify-plugin
fastify-hasura
A Fastify plugin to have fun with Hasura.
Stars: ✭ 30 (-55.88%)
Mutual labels:  fastify, fastify-plugin
fastify-angular-universal
Angular Universal integration to Fastify for rendering Angular apps on the server
Stars: ✭ 20 (-70.59%)
Mutual labels:  fastify, fastifyjs-plugin
fastify-env
Fastify plugin to check environment variables
Stars: ✭ 129 (+89.71%)
Mutual labels:  fastify, fastify-plugin
fastify-caching
A Fastify plugin to facilitate working with cache headers
Stars: ✭ 123 (+80.88%)
Mutual labels:  fastify, fastify-plugin
fastify-awilix
Dependency injection support for fastify
Stars: ✭ 52 (-23.53%)
Mutual labels:  fastify, fastify-plugin
fastify-nodemailer
Fastify nodemailer plugin
Stars: ✭ 23 (-66.18%)
Mutual labels:  fastify, fastifyjs-plugin
fastify-postgres
Fastify PostgreSQL connection plugin
Stars: ✭ 144 (+111.76%)
Mutual labels:  fastify, fastify-plugin
fastify-vue
A nuxt.js fastify plugin
Stars: ✭ 27 (-60.29%)
Mutual labels:  fastify, fastify-plugin
session
Session plugin for fastify
Stars: ✭ 52 (-23.53%)
Mutual labels:  fastify, fastify-plugin
fastify-cors
Fastify CORS
Stars: ✭ 212 (+211.76%)
Mutual labels:  fastify, fastify-plugin

fastify-file-upload

Fastify plugin to upload file.

Build Status NPM version

Note: the v3.x series of this module covers Fastify v3. For Fastify v2 support refert to the v2.x series.

Install

npm i fastify-file-upload --save

Usage

'use strict'

const fastify = require('fastify')()
const fileUpload = require('fastify-file-upload')

fastify.register(fileUpload)

fastify.post('/upload', function (req, reply) {
  // some code to handle file
  const files = req.raw.files
  console.log(files)
  let fileArr = []
  for(let key in files){
    fileArr.push({
      name: files[key].name,
      mimetype: files[key].mimetype
    })
  }
  reply.send(fileArr)
})

fastify.listen(3000, err => {
  if (err) throw err
  console.log(`server listening on ${fastify.server.address().port}`)
})

Use Schema Demo (fastify version >= 2)

fastify.post('/uploadSchema', {
  schema: {
    summary: 'upload file',
    body: {
      type: 'object',
      properties: {
        file: { type: 'object' }
      },
      required: ['file']
    }
  },
  handler: (request, reply) => {
    const file = request.body.file
    console.log(file)
    reply.send({ file })
  }
})

Using Busboy Options

fastify.register(fileUpload, {
  limits: { fileSize: 50 * 1024 * 1024 },
});

Available Options

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].