On Jul 1, 7:48 am, umrzyk <[EMAIL PROTECTED]> wrote:
> On 30 Cze, 03:51, Graham Dumpleton <[EMAIL PROTECTED]> wrote:
>
> > You may have to to ask the author of nginxmod_wsgiwhether streaming
> > uploads is even possible.
>
> > I vaguely remember from discussions, that due to nginxmod_wsgibeing
> > an event driven system, rather than using a threaded model, that it
> > may have to read complete request content into memory or onto disk
> > before it even executes the application. If it is into memory, then
> > what you are trying to do may not help as far as memory usage.
>
> > Graham
>
> i have just consulted this issue with author ofmod_wsgiand that
> looks a little bit different. nginx does not cache whole the request
> body in memory but instead (depending on size) makes use of temporary
> file. please take a look at 'client_body_buffer_size' parameter if you
> are interested in details.
>
> at last i also managed to get rid of "413 Entity too large" error. it
> was enough to increase 'client_max_body_size' parameter in nginx
> config.
>
> but i'm still unsure of one thing. while uploading small files i get
> in request.FILES instance of InMemoryUploadedFile, for large files
> this is TemporaryUploadedFile and that looks correct. Following is
> what documentation says about uploaded files handling:
>
> ,----[http://code.djangoproject.com/git/?p=django;a=blob_plain;f=docs/
> upload_handling.txt;hb=refs/heads/2070-streaming-uploads]
> |
> | Putting it all together, here's a common way you might handle an
> uploaded file::
> |
> |    def handle_uploaded_file(f):
> |        destination = open('some/file/name.txt', 'wb')
> |        for chunk in f.chunks():
> |            destination.write(chunk)
> `----
>
> and that is true for InMemoryUploadedFile as it has a chunks() method.
> TemporaryUploadedFile does not have this method, so I cannot use above
> snippet to handle both of them, or am i wrong? if so, what is the
> 'right' way to move uploaded file (no matter if it is InMemory- or
> Temporary- uploaded) to defined directory?

You can only use methods defined in WSGI specification as being valid
for wsgi.input. Thus, you need to ignore the actual type of object and
should not base decisions on it. See:

  http://www.python.org/dev/peps/pep-0333/#input-and-error-streams

Anything outside of read(), readline(), readlines() and __iter__() is
non standard and not portable. WSGI read() also has to be supplied a
length when calling it.

Graham

Graham
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to