fastify-multipart
Advanced tools
Comparing version 4.0.5 to 4.0.6
@@ -34,3 +34,3 @@ 'use strict' | ||
fastify.post('/upload/stream/files', async function (req, reply) { | ||
const parts = await req.files() | ||
const parts = req.files() | ||
for await (const part of parts) { | ||
@@ -43,3 +43,3 @@ await pump(part.file, fs.createWriteStream(part.filename)) | ||
fastify.post('/upload/raw/any', async function (req, reply) { | ||
const parts = await req.parts() | ||
const parts = req.parts() | ||
for await (const part of parts) { | ||
@@ -46,0 +46,0 @@ if (part.file) { |
@@ -446,3 +446,2 @@ 'use strict' | ||
request.unpipe(bb) | ||
bb.removeAllListeners() | ||
} | ||
@@ -449,0 +448,0 @@ |
{ | ||
"name": "fastify-multipart", | ||
"version": "4.0.5", | ||
"version": "4.0.6", | ||
"description": "Multipart plugin for Fastify", | ||
@@ -18,3 +18,3 @@ "main": "index.js", | ||
"@types/busboy": "^0.2.3", | ||
"@types/node": "^14.0.27", | ||
"@types/node": "^15.0.0", | ||
"@typescript-eslint/parser": "^4.0.0", | ||
@@ -37,3 +37,3 @@ "climem": "^1.0.3", | ||
"tap": "^15.0.1", | ||
"tsd": "^0.14.0", | ||
"tsd": "^0.15.0", | ||
"typescript": "^4.0.2" | ||
@@ -40,0 +40,0 @@ }, |
@@ -126,3 +126,3 @@ # fastify-multipart | ||
fastify.post('/', async function (req, reply) { | ||
const parts = await req.files() | ||
const parts = req.files() | ||
for await (const part of parts) { | ||
@@ -139,3 +139,3 @@ await pump(part.file, fs.createWriteStream(part.filename)) | ||
fastify.post('/upload/raw/any', async function (req, reply) { | ||
const parts = await req.parts() | ||
const parts = req.parts() | ||
for await (const part of parts) { | ||
@@ -190,6 +190,6 @@ if (part.file) { | ||
try { | ||
//const file = await req.file({ limits: { fileSize: 17000 } }) | ||
//const files = await req.files({ limits: { fileSize: 17000 } }) | ||
//const parts = await req.parts({ limits: { fileSize: 17000 } }) | ||
const files = await req.saveRequestFiles({ limits: { fileSize: 17000 } }) | ||
const file = await req.file({ limits: { fileSize: 17000 } }) | ||
//const files = req.files({ limits: { fileSize: 17000 } }) | ||
//const parts = req.parts({ limits: { fileSize: 17000 } }) | ||
//const files = await req.saveRequestFiles({ limits: { fileSize: 17000 } }) | ||
reply.send() | ||
@@ -211,4 +211,4 @@ } catch (error) { | ||
const file = await req.file({ throwFileSizeLimit: false, limits: { fileSize: 17000 } }) | ||
//const files = await req.files({ throwFileSizeLimit: false, limits: { fileSize: 17000 } }) | ||
//const parts = await req.parts({ throwFileSizeLimit: false, limits: { fileSize: 17000 } }) | ||
//const files = req.files({ throwFileSizeLimit: false, limits: { fileSize: 17000 } }) | ||
//const parts = req.parts({ throwFileSizeLimit: false, limits: { fileSize: 17000 } }) | ||
//const files = await req.saveRequestFiles({ throwFileSizeLimit: false, limits: { fileSize: 17000 } }) | ||
@@ -227,4 +227,7 @@ reply.send() | ||
fastify.post('/upload/files', async function (req, reply) { | ||
const uploadValue = await req.body.upload.toBuffer() // access files | ||
const fooValue = await req.body.foo.value // other fields | ||
const uploadValue = await req.body.upload.toBuffer() // access files | ||
const fooValue = req.body.foo.value // other fields | ||
const body = Object.fromEntries( | ||
Object.keys(req.body).map((key) => [key, req.body[key].value]) | ||
) // Request body in key-value pairs, like req.body in Express (Node 12+) | ||
}) | ||
@@ -243,3 +246,3 @@ ``` | ||
fastify.post('/upload/files', async function (req, reply) { | ||
const fooValue = await req.body.foo.value // other fields | ||
const fooValue = req.body.foo.value // other fields | ||
}) | ||
@@ -246,0 +249,0 @@ ``` |
@@ -99,3 +99,3 @@ import fastify from 'fastify' | ||
app.post('/', async (req, reply) => { | ||
const parts = await req.files() | ||
const parts = req.files() | ||
for await (const part of parts) { | ||
@@ -109,3 +109,3 @@ await pump(part.file, fs.createWriteStream(part.filename)) | ||
app.post('/upload/raw/any', async function (req, reply) { | ||
const parts = await req.parts() | ||
const parts = req.parts() | ||
for await (const part of parts) { | ||
@@ -112,0 +112,0 @@ if (part.file) { |
@@ -91,3 +91,3 @@ 'use strict' | ||
fastify.post('/', async function (req, reply) { | ||
const parts = await req.files() | ||
const parts = req.files() | ||
for await (const part of parts) { | ||
@@ -141,3 +141,3 @@ t.ok(part.file) | ||
fastify.post('/', async function (req, reply) { | ||
const parts = await req.parts() | ||
const parts = req.parts() | ||
for await (const part of parts) { | ||
@@ -288,3 +288,3 @@ t.ok(part) | ||
try { | ||
const parts = await req.files({ limits: { files: 1 } }) | ||
const parts = req.files({ limits: { files: 1 } }) | ||
for await (const part of parts) { | ||
@@ -341,3 +341,3 @@ t.ok(part.file) | ||
try { | ||
const parts = await req.files() | ||
const parts = req.files() | ||
for await (const part of parts) { | ||
@@ -494,3 +494,3 @@ t.ok(part.file) | ||
try { | ||
const parts = await req.files() | ||
const parts = req.files() | ||
for await (const part of parts) { | ||
@@ -545,3 +545,3 @@ t.ok(part.file) | ||
fastify.post('/', async function (req, reply) { | ||
const parts = await req.files({ limits: { fileSize: 1 } }) | ||
const parts = req.files({ limits: { fileSize: 1 } }) | ||
for await (const part of parts) { | ||
@@ -548,0 +548,0 @@ t.ok(part.file) |
Sorry, the diff of this file is not supported yet
129526
302
3688