上传大于 1 MB 的文件时出现 AWS 断管错误

AWS broken pipe error when uploading files bigger than 1 MB

我是一个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)

video是base64编码的视频文件('.mov','.avi','.mp4'等),image是base64编码的图片文件('.jpg','.png') base64编码。

这是我得到的轨迹,仅当总大小超过 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 政策上找到任何内容。

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

另请参阅 django 上传处理程序设置中为以下值设置的值

FILE_UPLOAD_MAX_MEMORY_SIZE

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