#26382: Improve Storage and FileField
--------------------------------------+-------------------------------
     Reporter:  cristianocca          |      Owner:  nobody
         Type:  Cleanup/optimization  |     Status:  new
    Component:  File uploads/storage  |    Version:  1.9
     Severity:  Normal                |   Keywords:  storage filefield
 Triage Stage:  Unreviewed            |  Has patch:  0
Easy pickings:  0                     |      UI/UX:  0
--------------------------------------+-------------------------------
 Hello, following this: https://groups.google.com/forum/#!topic/django-
 developers/CjoPZq8lZms

 It seems like the Storage and FileField classes are doing too much work
 that should be actually be delegated to the storage implementation, making
 it currently a bit more complicated to implement custom storages since the
 base Storage and FileField classes perform some os dependent work and
 based on assumptions like files should be always be saved with forward
 slashes or os dependant semantics like folders and paths.

 In particular, the methods get_directory_name, get_filename and
 generate_file_name from FileField
 
(https://github.com/django/django/blob/master/django/db/models/fields/files.py#L297)
 and the method save from Storage
 (https://github.com/django/django/blob/master/django/core/files/storage.py#L57)
 should be changed a bit so they delegate their work to the actual storage
 system.

 Finally for Storage.save, the below line should be moved to the ._save
 method of FileSystemStorage

 {{{
 # Store filenames with forward slashes, even on Windows
 return force_text(name.replace('\\', '/'))
 }}}

 I would move get_directory_name, get_filename and generate_file_name to
 the Storage class, however those methods also rely on the actual instance
 and upload_to value or callable and having those parameters sent to the
 storage class might not be a good idea. I'm not sure what would be the
 best way to remove any 'os.path' usage of FileField into the actual
 storage class without breaking everything.

--
Ticket URL: <https://code.djangoproject.com/ticket/26382>
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.b6d353a3936c2b13cccf07cbbcadc036%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to