You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -18,7 +18,7 @@ Under the hood it uses [`@fastify/busboy`](https://github.com/fastify/busboy).
18
18
19
19
## Install
20
20
```sh
21
-
npm i --save fastify-multipart
21
+
npm i --save @fastify/multipart
22
22
```
23
23
24
24
## Usage
@@ -33,7 +33,7 @@ const path = require('path')
33
33
const { pipeline } =require('stream')
34
34
constpump=util.promisify(pipeline)
35
35
36
-
fastify.register(require('fastify-multipart'))
36
+
fastify.register(require('@fastify/multipart'))
37
37
38
38
fastify.post('/', asyncfunction (req, reply) {
39
39
// process a single file
@@ -70,15 +70,15 @@ fastify.listen(3000, err => {
70
70
})
71
71
```
72
72
73
-
**Note** about `data.fields`: `busboy` consumes the multipart in serial order (stream). Therefore, the order of form fields is *VERY IMPORTANT* to how `fastify-multipart` can display the fields to you.
73
+
**Note** about `data.fields`: `busboy` consumes the multipart in serial order (stream). Therefore, the order of form fields is *VERY IMPORTANT* to how `@fastify/multipart` can display the fields to you.
74
74
We would recommend you place the value fields first before any of the file fields.
75
75
It will ensure your fields are accessible before it starts consuming any files.
76
76
If you cannot control the order of the placed fields, be sure to read `data.fields`*AFTER* consuming the stream, or it will only contain the fields parsed at that moment.
77
77
78
78
You can also pass optional arguments to `@fastify/busboy` when registering with Fastify. This is useful for setting limits on the content that can be uploaded. A full list of available options can be found in the [`@fastify/busboy` documentation](https://github.com/fastify/busboy#busboy-methods).
79
79
80
80
```js
81
-
fastify.register(require('fastify-multipart'), {
81
+
fastify.register(require('@fastify/multipart'), {
82
82
limits: {
83
83
fieldNameSize:100, // Max field name size in bytes
84
84
fieldSize:100, // Max field value size in bytes
@@ -226,7 +226,7 @@ fastify.post('/upload/file', async function (req, reply) {
226
226
This allows you to parse all fields automatically and assign them to the `request.body`. By default files are accumulated in memory (Be careful!) to buffer objects. Uncaught errors are [handled](https://github.com/fastify/fastify/blob/master/docs/Hooks.md#manage-errors-from-a-hook) by Fastify.
We export all custom errors via a server decorator `fastify.multipartErrors`. This is useful if you want to react to specific errors. They are derived from [fastify-error](https://github.com/fastify/fastify-error) and include the correct `statusCode` property.
405
+
We export all custom errors via a server decorator `fastify.multipartErrors`. This is useful if you want to react to specific errors. They are derived from [@fastify/error](https://github.com/fastify/fastify-error) and include the correct `statusCode` property.
0 commit comments