FileSystemStorage.save should support any file-like objects
|Reported by:||vzima||Owned by:||biern|
|Cc:||Triage Stage:||Ready for checkin|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
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:
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.
Change History (8)
comment:1 Changed 18 months ago by aaugustin
- Needs documentation unset
- Needs tests unset
- Patch needs improvement unset
- Triage Stage changed from Unreviewed to Accepted
- Type changed from Uncategorized to Cleanup/optimization
comment:5 Changed 14 months ago by biern
- Owner changed from nobody to biern
- Status changed from new to assigned
comment:7 Changed 14 months ago by gszczepanczyk
- Triage Stage changed from Accepted to Ready for checkin