1

我正在尝试将其整合python-swiftclient到我笨拙的 API 中,但遇到了一些麻烦。这是最简单的精简代码:

import swiftclient

url = "url-goes-here"
user = "my-user-goes-here"
key = "my-key-goes-here"

def get_token():
    return swiftclient.get_auth(url, user, key)[1]

def upload():
    theFile = open("/home/ivica/thefile.pdf", 'rb')
    token = get_token()

    resp = swiftclient.put_object(url,token,'test6','some name.pdf',theFile)

    print resp

upl()

该文件正在上传约 30 秒,然后弹出此错误:

File "/usr/lib/python2.7/site-packages/requests/api.py", line 44, in request
    return session.request(method=method, url=url, **kwargs)
  File "/usr/lib/python2.7/site-packages/requests/sessions.py", line 456, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/lib/python2.7/site-packages/requests/sessions.py", line 559, in send
    r = adapter.send(request, **kwargs)
  File "/usr/lib/python2.7/site-packages/requests/adapters.py", line 372, in send
    raise ConnectionError(sockerr, request=request)
requests.exceptions.ConnectionError: [Errno 32] Broken pipe
4

0 回答 0