Impossible to stop a large file upload mid-stream
|Reported by:||legutierr||Owned by:||nobody|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
As described in this post on the django-users group, raising django.core.files.uploadhandler.StopUpload(connection_reset=True) in order to cut off a too-large file upload does not work as documented. Nor does it work as specified in comments to the code, nor according to a discussion regarding the implementation of this feature.
The connection reset functionality does work correctly using the development server, but not using mod_python or fastcgi on lighttpd or Apache. It seems that in both cases the webserver pre-loads the entire file, regardless of its size, without Django taking the opportunity to interrupt the stream, even if StopUpload(connection_reset=True) is raised by receive_data_chunk() inside a subclass of FileUploadHandler.
The most egregious side effect of this defect is that while the file is uploading to the server, the server experiences significant slow-downs.
In addition, without a fix, any restrictions on file-size for upload will not be delivered to users until they have waited for many minutes uploading their unacceptable file, a user-interaction failure that should be avoidable.
Change History (11)
comment:1 Changed 7 years ago by grahamd
- Needs documentation unset
- Needs tests unset
- Patch needs improvement unset