Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting http.client.RemoteDisconnected while uploading certain files #17

Open
alanszlosek opened this issue Aug 15, 2018 · 2 comments
Open

Comments

@alanszlosek
Copy link

I'm able to upload most of my jpeg files just fine, but certain ones cause me issues.

Trying to upload this image with the following code:

p1000977

from b2blaze import B2

b2 = B2(key_id="bla", application_key="bla")
bucket = b2.buckets.get('test-bucket-name')

input = open('/PATH/TO/IMAGE.JPG', 'rb')
bucket.files.upload(contents=input, file_name='test.jpg', mime_content_type='image/jpeg')
@sibblegp
Copy link
Owner

Did you try not setting a mime_content_type? It can automatically detect it.

@alanszlosek
Copy link
Author

I left off the mime_content_type parameter and got the same behavior. Here's the output:

Traceback (most recent call last):
  File "/Users/alanszlosek/Projects/cloud-images/venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 600, in urlopen
    chunked=chunked)
  File "/Users/alanszlosek/Projects/cloud-images/venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 384, in _make_request
    six.raise_from(e, None)
  File "<string>", line 2, in raise_from
  File "/Users/alanszlosek/Projects/cloud-images/venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 380, in _make_request
    httplib_response = conn.getresponse()
  File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1321, in getresponse
    response.begin()
  File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 296, in begin
    version, status, reason = self._read_status()
  File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 265, in _read_status
    raise RemoteDisconnected("Remote end closed connection without"
http.client.RemoteDisconnected: Remote end closed connection without response

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/alanszlosek/Projects/cloud-images/venv/lib/python3.7/site-packages/requests/adapters.py", line 445, in send
    timeout=timeout
  File "/Users/alanszlosek/Projects/cloud-images/venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 638, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/Users/alanszlosek/Projects/cloud-images/venv/lib/python3.7/site-packages/urllib3/util/retry.py", line 367, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "/Users/alanszlosek/Projects/cloud-images/venv/lib/python3.7/site-packages/urllib3/packages/six.py", line 685, in reraise
    raise value.with_traceback(tb)
  File "/Users/alanszlosek/Projects/cloud-images/venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 600, in urlopen
    chunked=chunked)
  File "/Users/alanszlosek/Projects/cloud-images/venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 384, in _make_request
    six.raise_from(e, None)
  File "<string>", line 2, in raise_from
  File "/Users/alanszlosek/Projects/cloud-images/venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 380, in _make_request
    httplib_response = conn.getresponse()
  File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1321, in getresponse
    response.begin()
  File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 296, in begin
    version, status, reason = self._read_status()
  File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 265, in _read_status
    raise RemoteDisconnected("Remote end closed connection without"
urllib3.exceptions.ProtocolError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "src/test2.py", line 9, in <module>
    bucket.files.upload(contents=input, file_name='test.jpg') #, mime_content_type='image/jpeg')
  File "/Users/alanszlosek/Projects/cloud-images/venv/lib/python3.7/site-packages/b2blaze/models/file_list.py", line 132, in upload
    content_length=content_length, progress_listener=progress_listener)
  File "/Users/alanszlosek/Projects/cloud-images/venv/lib/python3.7/site-packages/b2blaze/connector.py", line 135, in upload_file
    return requests.post(upload_url, headers=headers, data=data)
  File "/Users/alanszlosek/Projects/cloud-images/venv/lib/python3.7/site-packages/requests/api.py", line 112, in post
    return request('post', url, data=data, json=json, **kwargs)
  File "/Users/alanszlosek/Projects/cloud-images/venv/lib/python3.7/site-packages/requests/api.py", line 58, in request
    return session.request(method=method, url=url, **kwargs)
  File "/Users/alanszlosek/Projects/cloud-images/venv/lib/python3.7/site-packages/requests/sessions.py", line 512, in request
    resp = self.send(prep, **send_kwargs)
  File "/Users/alanszlosek/Projects/cloud-images/venv/lib/python3.7/site-packages/requests/sessions.py", line 622, in send
    r = adapter.send(request, **kwargs)
  File "/Users/alanszlosek/Projects/cloud-images/venv/lib/python3.7/site-packages/requests/adapters.py", line 495, in send
    raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants