上传大于1 MB的文件时AWS破坏管道错误

时间:2017-11-18 14:33:41

标签: django amazon-s3 broken-pipe

我是一个django新手,我继承了一个django后端,只有很少的文档。我正在向服务器发出请求,该服务器托管在AWS上。要将文件存储在请求中,我们使用S3。 我在django代码上没有发现任何限制文件上传大小的内容,我怀疑由于文件大小,AWS可能会关闭连接。

这是我使用的代码,并且只要文件的总大小超过1 MB,我就会得到错误:

import requests
json_dict = {'key_1':'value_1','video':video,'image':,image}
requests.post('https://api.test.whatever.io/v1/register', json=dict_reg)

视频是带有base64编码的视频文件('.mov','。avi','。mp4'等),而image是带有base64编码的图像文件('.jpg','。png')

这是我得到的痕迹,仅当总大小超过1 MB时:

/usr/local/lib/python2.7/dist-
packages/requests/packages/urllib3/util/ssl_.py:132: InsecurePlatfo
rmWarning: A true SSLContext object is not available. This prevents urllib3 
from configuring SSL
appropriately and may cause certain SSL connections to fail. You can upgrade 
to a newer version of Python to solve this. For more information, see 
https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
InsecurePlatformWarningTraceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/requests/api.py", line 110, in 
post
return request('post', url, data=data, json=json, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests/api.py", line 56, in 
request
return session.request(method=method, url=url, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 
488, in request
resp = self.send(prep, **send_kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 
609, in send
r = adapter.send(request, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests/adapters.py", line 
473, in send
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', error(32, 
'Broken pipe'))

如前所述,我没有在django代码中的任何地方找到文件大小的限制,我应该看到的任何提示? 我也没有在AWS S3策略中找到任何内容。

2 个答案:

答案 0 :(得分:2)

假设您有一个Nginx来反向代理您的HTTP请求?如果是,请检查此link

另请参阅django

中上传处理程序设置中以下值的设置值
FILE_UPLOAD_MAX_MEMORY_SIZE

答案 1 :(得分:1)

最后是nginx配置。将client_max_body_size文件中的变量nginx.conf1M更改为2M就可以了。