
Product
Introducing Socket Firewall Enterprise: Flexible, Configurable Protection for Modern Package Ecosystems
Socket Firewall Enterprise is now available with flexible deployment, configurable policies, and expanded language support.
@damirn/fastify-formidable
Advanced tools
[](https://github.com/climba03003/fastify-formidable/actions/workflows/ci.yml) [
fastify.post('/', async function(request, reply) {
// you need to call the parser if you do not pass any option through plugin registration
await request.parseMultipart()
// access files
request.files
// access body
// note that file fields will exist in body and it will becomes the file path saved on disk
request.body
// access all the files path
request[kFileSavedPaths]
// check if it is multipart
if( request[kIsMultipart] === true ) {}
// check if it is already parsed
if ( request[kIsMultipartParsed] === true ) {}
})
// add content type parser which will automatic parse all `multipart/form-data` found
fastify.register(FastifyFormidable, {
addContentTypeParser: true
})
// add `preValidation` hook which will automatic parse all `multipart/form-data` found
fastify.register(FastifyFormidable, {
addHooks: true
})
The options which will be directly passed to formidable.
import FastifyFormidable from 'fastify-formidable'
fastify.register(FastifyFormidable, {
formidable: {
maxFileSize: 1000,
// this folder will be automatic created by this plugin
uploadDir: '/'
}
})
See: formidable
This options will add a preHandler hooks to remove files from body.
import FastifyFormidable from 'fastify-formidable'
fastify.register(FastifyFormidable, {
removeFilesFromBody: true
})
It is a known limitation for fastify-multipart integrate with fastify-swagger and this plugin provide a relatively simple solution for the integration.
import Fastify from 'fastify'
import FastifyFormidable, { ajvBinaryFormat } from 'fastify-formidable'
import FastifySwagger from 'fastify-swagger'
const fastify = Fastify({
ajv: {
plugins: [ ajvBinaryFormat ]
}
})
fastify.register(FastifyFormidable, {
addContentTypeParser: true
})
fastify.register(FastifySwagger)
FAQs
[](https://github.com/climba03003/fastify-formidable/actions/workflows/ci.yml) [
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.

Product
Socket Firewall Enterprise is now available with flexible deployment, configurable policies, and expanded language support.

Security News
Open source dashboard CNAPulse tracks CVE Numbering Authorities’ publishing activity, highlighting trends and transparency across the CVE ecosystem.

Product
Detect malware, unsafe data flows, and license issues in GitHub Actions with Socket’s new workflow scanning support.