fastify-multipart
Advanced tools
Comparing version 5.2.0 to 5.2.1
@@ -57,13 +57,13 @@ import { Busboy, BusboyConfig } from "@fastify/busboy"; | ||
// promise api | ||
parts: (options?: BusboyConfig) => AsyncIterableIterator<Multipart> | ||
parts: (options?: Omit<BusboyConfig, 'headers'>) => AsyncIterableIterator<Multipart> | ||
// legacy | ||
multipart: (handler: MultipartHandler, next: (err: Error) => void, options?: BusboyConfig) => Busboy; | ||
multipart: (handler: MultipartHandler, next: (err: Error) => void, options?: Omit<BusboyConfig, 'headers'>) => Busboy; | ||
// Stream mode | ||
file: (options?: BusboyConfig) => Promise<Multipart> | ||
files: (options?: BusboyConfig) => AsyncIterableIterator<Multipart> | ||
file: (options?: Omit<BusboyConfig, 'headers'>) => Promise<Multipart> | ||
files: (options?: Omit<BusboyConfig, 'headers'>) => AsyncIterableIterator<Multipart> | ||
// Disk mode | ||
saveRequestFiles: (options?: BusboyConfig & { tmpdir?: string }) => Promise<Array<Multipart>> | ||
saveRequestFiles: (options?: Omit<BusboyConfig, 'headers'> & { tmpdir?: string }) => Promise<Array<Multipart>> | ||
cleanRequestFiles: () => Promise<void> | ||
@@ -94,2 +94,12 @@ tmpUploads: Array<Multipart> | ||
/** | ||
* Detect if a Part is a file. | ||
* | ||
* By default a file is detected if contentType | ||
* is application/octet-stream or fileName is not | ||
* undefined. | ||
* | ||
* Modify this to handle e.g. Blobs. | ||
*/ | ||
isPartAFile?: (fieldName: string | undefined, contentType: string | undefined, fileName: string | undefined) => boolean; | ||
@@ -96,0 +106,0 @@ limits?: { |
{ | ||
"name": "fastify-multipart", | ||
"version": "5.2.0", | ||
"version": "5.2.1", | ||
"description": "Multipart plugin for Fastify", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -49,3 +49,2 @@ import fastify from 'fastify' | ||
}, { | ||
headers: { 'content-type': 'multipart/form-data' }, | ||
limits: { | ||
@@ -94,3 +93,3 @@ fileSize: 10000 | ||
app.post('/', async function (req, reply) { | ||
const options: BusboyConfig = { headers: { 'content-type': 'multipart/form-data' }, limits: { fileSize: 1000 } }; | ||
const options: Partial<BusboyConfig> = { limits: { fileSize: 1000 } }; | ||
const data = await req.file(options) | ||
@@ -147,3 +146,3 @@ await pump(data.file, fs.createWriteStream(data.filename)) | ||
app.post('/upload/files', async function (req, reply) { | ||
const options: BusboyConfig = { headers: { 'content-type': 'multipart/form-data' }, limits: { fileSize: 1000 } }; | ||
const options: Partial<BusboyConfig> = { limits: { fileSize: 1000 } }; | ||
await req.saveRequestFiles(options) | ||
@@ -150,0 +149,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
147489
4191