Skip to content

Commit 67f1c99

Browse files
Merge pull request #2511 from thiagomini/patch-4
docs: add a warning for FileTypeValidator
2 parents 608e40a + 2679dc3 commit 67f1c99

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

content/techniques/file-upload.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ export abstract class FileValidator<TValidationOptions = Record<string, any>> {
120120
- `MaxFileSizeValidator` - Checks if a given file's size is less than the provided value (measured in `bytes`)
121121
- `FileTypeValidator` - Checks if a given file's mime-type matches the given value.
122122

123+
> warning **Warning** The [FileTypeValidator](https://github.com/nestjs/nest/blob/master/packages/common/pipes/file/file-type.validator.ts) class uses a naive implementation to verify the incoming file's type. Consider using a custom implementation (like checking the file's [magic number](https://www.ibm.com/support/pages/what-magic-number)) if your app requires a safer solution.
124+
123125
To understand how these can be used in conjunction with the beforementioned `FileParsePipe`, we'll use an altered snippet of the last presented example:
124126

125127
```typescript

0 commit comments

Comments
 (0)