#22718: django.core.files.File doesn't handle certain file-like objects (e.g.
zipfile.ZipExtFile)
--------------------------------------+------------------------------------
Reporter: linkjuggler@… | Owner: mshafiq9
Type: Bug | Status: assigned
Component: File uploads/storage | Version: 1.6
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Comment (by mshafiq9):
Digged down in this issue on EuroPython 2014 Django Sprint, and If I break
the `zfile = File(zip.open("dir/file.txt")` as below
{{{
opened_zip_file = zip.open("dir/file.txt")
zfile = File(opened_zip_file)
}}}
and inspect on the `opened_zip_file` its an instance of `class
ZipExtFile(io.BufferedIOBase):`
http://hg.python.org/cpython/file/2.7/Lib/zipfile.py#l501 which being
`file-like object` do not support seek interface on this file instance
(also return `False` if you check `opened_zip_file.seekable()`).
1 - If we want to improve the `python zipfile library` to support this
interface (if necessary?) the correct fix should be done by cpython.
2 - I don't see a practical example of this happening (to send `file-like`
objects directly to django `FileField`) without being involved a user's
custom logic, so I think this is an individual user's problem (not
Django's) to solve it by using some trick / extracting zip file in `/tmp`
directory of server or something like this. ***I think some core django
developer (if agreed?) please mark this ticket as invalid and close it.***
3 - Another peer sitting around suggested to develop a `ZipFileField` but
I think I don't see any usage of it currently! (if someone need it please
define some standard usage, interfaces, and examples and ask for a new
feature ticket and I will appreciate if you place the link of the new
ticket here if you do so! I might pick that one later).
--
Ticket URL: <https://code.djangoproject.com/ticket/22718#comment:3>
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/079.a07a3c413b54869bf33ffc0120f70e78%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.