Skip to content

Commit d59d85f

Browse files
Merge pull request #3248 from phlogisticfugu/patch-1
Update file-upload.md for secured FileTypeValidator
2 parents db63134 + cb449fa commit d59d85f

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

content/techniques/file-upload.md

+1-3
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,7 @@ export abstract class FileValidator<TValidationOptions = Record<string, any>> {
131131
`FileValidator` is a regular class that has access to the file object and validates it according to the options provided by the client. Nest has two built-in `FileValidator` implementations you can use in your project:
132132

133133
- `MaxFileSizeValidator` - Checks if a given file's size is less than the provided value (measured in `bytes`)
134-
- `FileTypeValidator` - Checks if a given file's mime-type matches the given value.
135-
136-
> warning **Warning** To verify file type, [FileTypeValidator](https://github.com/nestjs/nest/blob/master/packages/common/pipes/file/file-type.validator.ts) class uses the type as detected by multer. By default, multer derives file type from file extension on user's device. However, it does not check actual file contents. As files can be renamed to arbitrary extensions, 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.
134+
- `FileTypeValidator` - Checks if a given file's mime-type matches a given string or RegExp. By default, validates the mime-type using file content [magic number](https://www.ibm.com/support/pages/what-magic-number)
137135

138136
To understand how these can be used in conjunction with the aforementioned `FileParsePipe`, we'll use an altered snippet of the last presented example:
139137

0 commit comments

Comments
 (0)