Opened 3 months ago

Closed 3 months ago

Last modified 3 months ago

#33942 closed New feature (wontfix)

file validator - validating file with mime and magic numbers

Reported by: Reza Shakeri Owned by: nobody
Component: File uploads/storage Version: 4.0
Severity: Normal Keywords: file-validator, file, validator
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Reza Shakeri)

I want to add a file validator to Django using the native Python library called mimetypes https://docs.python.org/3/library/mimetypes.html
There is a file validator in Django, but it only validates files using the extension, which is not very reliable. According to the documentation, I wrote a file validator that checks the magic numbers (mimes) of the files In addition to file extensions, and it is more reliable and reliable with It supports the use of native Python libraries and many mimes, This file validator can check the size of files in addition to mimes and validate both of them.

I wrote a file validator library using Python, which you can use using the link below and see its codes:
https://github.com/rzashakeri/file_validator

The file validator code that I wrote myself and you can check:
https://github.com/rzashakeri/file_validator/blob/cfdb9cc90dba9708d895f18095a8177cd3392779/file_validator/django.py#L92

Change History (11)

comment:1 Changed 3 months ago by Reza Shakeri

Description: modified (diff)

comment:2 Changed 3 months ago by Reza Shakeri

Summary: file validatorfile validator - validate file use mime

comment:3 Changed 3 months ago by Reza Shakeri

Summary: file validator - validate file use mimefile validator - validating file with mime and file magic numbers

comment:4 Changed 3 months ago by Reza Shakeri

Summary: file validator - validating file with mime and file magic numbersfile validator - validating file with mime and magic numbers

comment:5 Changed 3 months ago by Reza Shakeri

Description: modified (diff)
Summary: file validator - validating file with mime and magic numbersfile validator

comment:6 Changed 3 months ago by Reza Shakeri

Summary: file validatorfile validator - validating file with mime and magic numbers

comment:7 Changed 3 months ago by Reza Shakeri

Description: modified (diff)

comment:8 Changed 3 months ago by Reza Shakeri

Description: modified (diff)

comment:9 Changed 3 months ago by Reza Shakeri

Description: modified (diff)

comment:10 Changed 3 months ago by Carlton Gibson

Resolution: wontfix
Status: newclosed

Hi Reza.

You've marked this as a new feature, so I guess you want to include this in core. I'll say no at first pass, since complicating the built-in validators isn't really on the agenda.
Folks are very able to create their own, as you've done here. There'd need to be a consensus to include more logic here via a discussion on the DevelopersMailingList.

You can also tell folks about your validator on the Show & Tell category on the Django Forum. (More generally see TicketClosingReasons/UseSupportChannels).

Thanks.

comment:11 Changed 3 months ago by Reza Shakeri

Thanks

Note: See TracTickets for help on using tickets.
Back to Top