#18899: FileSystemStorage.save should support any file-like objects --------------------------------------+-------------------- Reporter: vzima | Owner: nobody Type: Uncategorized | Status: new Component: File uploads/storage | Version: 1.4 Severity: Normal | Keywords: Triage Stage: Unreviewed | Has patch: 0 Easy pickings: 0 | UI/UX: 0 --------------------------------------+-------------------- I propose generic support of `FileSystemStorage.save()`, so `content` argument can be any object with `read([size])` method.
I see no reason why `FileSystemStorage` does not support regular file-like objects. IT is common practise to support any file-like objects in python libraries, where file-like object is an argument. Blocker of this is `content.chunks()` call which itself is nothing else then generator over `file.read(chunk_size)`. Storage itself could easily call `content.read(chunk_size)` directly which grants support to various file-like objects. Calls like this are just weird: {{{ #!python storage.save(target, File(open(filename))) }}} The `File` objects is here only because it has `chunks()` method required by `FileSystemStorage.save()` call. I have seen #8204 but I do not require anything so specific. It is just painful, when you want to use storage for anything else than file from query or form. -- Ticket URL: <https://code.djangoproject.com/ticket/18899> 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 post to this group, send email to django-updates@googlegroups.com. To unsubscribe from this group, send email to django-updates+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.