将二进制文件上载到Openstack Swift会出错

时间:2017-06-14 09:38:15

标签: openstack openstack-swift

我正在尝试将我必须的二进制文件上传到Openstack Swift。此文件的此大小为129MB。我正在使用Python客户端进行上传:

swift_client = swiftclient.Connection(preauthurl=swift_public_auth_url,preauthtoken=swift_access_token,auth_version="2.0",insecure=True,tenant_name="admin")
with open("/path/to/file/file.ckpt", 'r') as read_file:
    swift_client.put_object(swift_container_name, 'file.ckpt', contents= read_file.read(),content_type='text/plain')
    print "done"

这会引发以下错误:

Traceback (most recent call last):
  File "<stdin>", line 2, in <module>
  File "/usr/local/lib/python2.7/dist-packages/swiftclient/client.py", line 1824, in put_object
    response_dict=response_dict)
  File "/usr/local/lib/python2.7/dist-packages/swiftclient/client.py", line 1673, in _retry
    service_token=self.service_token, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/swiftclient/client.py", line 1322, in put_object
    raise ClientException.from_response(resp, 'Object PUT failed', body)
swiftclient.exceptions.ClientException: Object PUT failed: https://abc.xyz/swift/v1/AUTH_123456789abcdefghijklmn/container/file.ckpt 413 Request Entity Too Large  [first 60 chars of response] <html>
<head><title>413 Request Entity Too Large</title></h

然而,当我尝试用空白文本文件test.txt替换test.ckpt时,它上传了相同的参数。我知道当文件大小超过5GB时会发生此错误,但这可能是什么问题?

1 个答案:

答案 0 :(得分:1)

发现问题是由于我的Nginx代理服务器上的配置。通过增加client_max_body_size来解决问题。更多详情:https://www.cyberciti.biz/faq/linux-unix-bsd-nginx-413-request-entity-too-large/