#34441: A new require_files decorator for file validation in Django Framework
-------------------------------------+-------------------------------------
               Reporter:  Raza Ul    |          Owner:  nobody
  Mustafa                            |
                   Type:  New        |         Status:  new
  feature                            |
              Component:  File       |        Version:  4.1
  uploads/storage                    |
               Severity:  Normal     |       Keywords:  decorator
           Triage Stage:             |      Has patch:  1
  Unreviewed                         |
    Needs documentation:  0          |    Needs tests:  0
Patch needs improvement:  0          |  Easy pickings:  0
                  UI/UX:  0          |
-------------------------------------+-------------------------------------
 I am interested in adding a new decorator in Django. This decorator will
 be used for file validation purposes.

 This decorator checks the file extensions and size. If the file extensions
 and size provided by the developer are not in the request.FILES then it
 will raise errors. In this way, developers don't need to modify their
 functions to check the file validations.

 For example,
 {{{
 @require_files(["pdf", "txt", 20])
 def file_upload_view(request):
     return HttpResposne("Successful")
 }}}
 Here this decorator will check if the file types are (pdf or txt) else
 will raise TypeError.  Also, check if each file size is less than 20 MB.
 If not, will raise IOError.

 I had already started working on this decorator and had written multiple
 tests. So the functionality is almost implemented.
 This feature is useful for improving the security and reliability of file
 uploads in the project, as it prevents users from uploading files that may
 cause server issues or contain malicious content.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/34441>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018724fc60c5-f852a63c-ff67-47bb-968b-3a7eefbc3ad9-000000%40eu-central-1.amazonses.com.

Reply via email to