[BangPypers] Question regarding memory of uploaded files in Django

Noufal Ibrahim KV noufal at nibrahim.net.in
Mon Dec 30 09:34:22 CET 2013


On Mon, Dec 30 2013, Pranjal Mittal wrote:

> Hi,
>
> I had a question regarding how *InMemoryUploadedFiles* work in Django.
> I posted the question in Stackoverflow. Haven't got a good answer yet.
> http://stackoverflow.com/questions/20827939/is-inmemoryuploadedfile-really-in-memory
>
> Any one has a clue on how InMemoryUploadedFile(s) work in Django? If its a
> file like object, or a file handle then is it really "in memory" ie. If I
> upload a file of larger size then is the InMemoryUploadedFile object also
> of a greater size or is it independent of that.
>
> *To elaborate:*
>
> AFAIK, when you open a file in Python, it returns a handle to the file
> which takes the same memory irrespective of the size of the file being
> opened. It is when you peform the *read()* operation, that the file is
> really read into the memory. *InMemoryUploadedFile* type does have a read()
> method; So does that make InMemoryUploadedFile a file handle itself, which
> is independent of the uploaded file size?

The docs suggest that it's a stream-to-memory object which means that
the data will be read out of the stream and be made available to you for
processing. I'm not sure how (or if) it will buffer this and what the
memory characteristics are. I think they're calling this (and other
objects) `File` because they offer a file like interface.



[...]


-- 
Cordially,
Noufal
http://nibrahim.net.in


More information about the BangPypers mailing list