我正在尝试使用带有http请求的MultipartEntityBuilder
(java)从Android设备发送多个文件(图像和音频)。每次请求包括文件到达服务器并按预期工作,但有时(10%)django服务器无法读取请求的内容。
在浏览了与此问题相关的所有链接后,我发现由于已损坏的请求可能会发生此问题,即如果有人在中间取消了请求。
由于我的请求是AsyncTask
,请求不应该中断。
我知道这个问题已经被问到了。由于我没有从这些帖子中得到适当的解决方案,我想重新打开这个问题。因此,请尝试给我一些启示,而不是将其设为
duplicate
。
链接: -
服务器日志:
Traceback (most recent call last):
File "/var/www/html/prototype/version1/views.py", line 2515, in manage_app_data
print request.FILES
File "/usr/local/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 165, in _get_files
self._load_post_and_files()
File "/usr/local/lib/python2.7/site-packages/django/http/request.py", line 215, in _load_post_and_files
self._post, self._files = self.parse_file_upload(self.META, data)
File "/usr/local/lib/python2.7/site-packages/django/http/request.py", line 180, in parse_file_upload
return parser.parse()
File "/usr/local/lib/python2.7/site-packages/django/http/multipartparser.py", line 140, in parse
for item_type, meta_data, field_stream in Parser(stream, self._boundary):
File "/usr/local/lib/python2.7/site-packages/django/http/multipartparser.py", line 598, in __iter__
for sub_stream in boundarystream:
File "/usr/local/lib/python2.7/site-packages/django/utils/six.py", line 473, in next
return type(self).__next__(self)
File "/usr/local/lib/python2.7/site-packages/django/http/multipartparser.py", line 415, in __next__
return LazyStream(BoundaryIter(self._stream, self._boundary))
File "/usr/local/lib/python2.7/site-packages/django/http/multipartparser.py", line 441, in __init__
unused_char = self._stream.read(1)
File "/usr/local/lib/python2.7/site-packages/django/http/multipartparser.py", line 315, in read
out = b''.join(parts())
File "/usr/local/lib/python2.7/site-packages/django/http/multipartparser.py", line 308, in parts
chunk = next(self)
File "/usr/local/lib/python2.7/site-packages/django/utils/six.py", line 473, in next
return type(self).__next__(self)
File "/usr/local/lib/python2.7/site-packages/django/http/multipartparser.py", line 330, in __next__
output = next(self._producer)
File "/usr/local/lib/python2.7/site-packages/django/utils/six.py", line 473, in next
return type(self).__next__(self)
File "/usr/local/lib/python2.7/site-packages/django/http/multipartparser.py", line 391, in __next__
data = self.flo.read(self.chunk_size)
File "/usr/local/lib/python2.7/site-packages/django/http/request.py", line 244, in read
six.reraise(UnreadablePostError, UnreadablePostError(*e.args), sys.exc_info()[2])
File "/usr/local/lib/python2.7/site-packages/django/http/request.py", line 242, in read
return self._stream.read(*args, **kwargs)
File "/usr/local/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 51, in read
result = self.buffer + self._read_limited(size - len(self.buffer))
File "/usr/local/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 39, in _read_limited
result = self.stream.read(size)
UnreadablePostError: request data read error
如何解决?出了什么问题?