#33023: InMemoryUploadedFile - opening with context manager multiple time is
throwing error
--------------------------------+--------------------------------------
Reporter: Harsh Bhikadia | Owner: nobody
Type: Bug | Status: closed
Component: Core (Other) | Version: 3.2
Severity: Normal | Resolution: wontfix
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------+--------------------------------------
Changes (by Carlton Gibson):
* status: new => closed
* resolution: => wontfix
Comment:
Hi. Thanks for the report.
I don't think it's worth complicating the `UploadedFile` code here. It's a
way of Django passing the file data to your application. If you need to
process that data multiple times you should save it to a suitable location
(which may be in memory) and then use that, which is fully under your
control. (That the file will be closed on exiting the context manager
allows the memory to be released. That's the right behaviour, that we'd
want to maintain.)
> Not sure why the "open" method was overridden
It's required to ensure the `BytesIO` instance is ready to read. It's been
there for many years, at least since the current file upload structure was
introduced. See #2070 (d725cc9734272f867d41f7236235c28b3931a1b2).
--
Ticket URL: <https://code.djangoproject.com/ticket/33023#comment:4>
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 view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/063.94307a024375007f10bccf82af76af22%40djangoproject.com.