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
Copy file name to clipboardExpand all lines: content/techniques/file-upload.md
+11-3Lines changed: 11 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,6 +4,14 @@ To handle file uploading, Nest provides a built-in module based on the [multer](
4
4
5
5
> warning **Warning** Multer cannot process data which is not in the supported multipart format (`multipart/form-data`). Also, note that this package is not compatible with the `FastifyAdapter`.
6
6
7
+
For better type safety, let's install Multer typings package:
8
+
9
+
```shell
10
+
$ npm i -D @types/multer
11
+
```
12
+
13
+
With this package installed, we can now use the `Express.Multer.File` type (you can import this type as follows: `import {{ '{' }} Express {{ '}' }} from 'express'`).
14
+
7
15
#### Basic example
8
16
9
17
To upload a single file, simply tie the `FileInterceptor()` interceptor to the route handler and extract `file` from the `request` using the `@UploadedFile()` decorator.
@@ -12,7 +20,7 @@ To upload a single file, simply tie the `FileInterceptor()` interceptor to the r
0 commit comments