#26367: Minor FieldFile (proxy for FieldFile) improvement?
--------------------------------------+--------------------------
     Reporter:  cristianocca          |      Owner:  nobody
         Type:  Cleanup/optimization  |     Status:  new
    Component:  File uploads/storage  |    Version:  1.9
     Severity:  Normal                |   Keywords:  file storage
 Triage Stage:  Unreviewed            |  Has patch:  0
Easy pickings:  0                     |      UI/UX:  0
--------------------------------------+--------------------------
 The FileField docs
 
(https://docs.djangoproject.com/es/1.9/ref/models/fields/#django.db.models.FileField)
 state that in order to save a file into a FileField (through FieldFile
 proxy) you need a django File object and not a regular one.

 Looking at the code
 
(https://github.com/django/django/blob/master/django/db/models/fields/files.py#L92
 ) it seems like the only reason to have a File object is because it needs
 the 'size' property which isn't available on every file-like object.
 Looking into the same file, it doesn't seem anyone uses _size anymore,
 only its parent class, BUT, this class actually overrides the size
 property so it is not calling the parent class .size (and if it did, it
 would cache it).

 Would it be possible to remove any _size from FieldFile and then test
 against regular file-like objects rather than "File" and if everything
 works change the docs?
 The only other place a File is required is at FileSystemStorage._save,
 however, since you don't call ._save but instead .save which already
 converts any file into a File (and it is also stated in the docs that the
 Storage.save method can accept any file), the requierement for a File
 seems unnecessary.

 There's also a topic here https://groups.google.com/forum/#!topic/django-
 developers/CjoPZq8lZms that might suggest that the storage and file field
 classes require a few improvements.

--
Ticket URL: <https://code.djangoproject.com/ticket/26367>
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 post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/055.61dbee078eb35d856b053a093a10ce96%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to