Skip to content

Commit

Permalink
Merge branch 'gyanendrasng-update-file-validation-docs'
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilmysliwiec committed Nov 7, 2024
2 parents e014e7e + e65cb48 commit c2ec8a0
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions content/techniques/file-upload.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,19 @@ export class FileSizeValidationPipe implements PipeTransform {
}
```

This can be used in conjunction with the `FileInterceptor` as follows:

```typescript
@Post('file')
@UseInterceptors(FileInterceptor('file'))
uploadFileAndValidate(@UploadedFile(
new FileSizeValidationPipe(),
// other pipes can be added here
) file: Express.Multer.File, ) {
return file;
}
```

Nest provides a built-in pipe to handle common use cases and facilitate/standardize the addition of new ones. This pipe is called `ParseFilePipe`, and you can use it as follows:

```typescript
Expand Down

0 comments on commit c2ec8a0

Please sign in to comment.