Django: Large file uploads - custom processing with mod_wsgi
-
05-07-2019 - |
Question
I'm doing file uploads using Django's File Upload mechanism with a custom handler (by subclassing django.core.files.uploadhandler.FileUploadHandler
) which does some additional processing in the
receive_data_chunk(self, raw_data, start)
function.
I was curious when the handler is actually called (i.e. after the file has been completely uploaded by the server or as it arrives on the socket)?
From my tests I found out that you have access to the data as it arrives on the socket, but I would like someone to confirm this. I'm a little puzzled by this, because I thought mod_wsgi
was a content generator
in Apache, thus being called after the input filters
which pre-process the client's request.
PS: I'm using Apache + mod_wsgi + Django.
Solution
In Apache, input filters are only applied to input content when the request handler reads the input content. So, no preprocessing is done by input filters, it is done inline with the request handler consuming the input content.