Imgur / imgurpython

Official Imgur python client library (deprecated)
MIT License
544 stars 116 forks source link

ImgurClientError (500) when uploading from path #90

Closed void4 closed 6 years ago

void4 commented 6 years ago

When trying to run

from imgurpython import ImgurClient

client_id = "XXXXXXXXXXXXXX"
client_secret = "XXXXXXXXXXXXXX"
access_token = "XXXXXXXXXXXXXX"
refresh_token = "XXXXXXXXXXXXXX"
imgur_client = ImgurClient(client_id, client_secret, access_token, refresh_token)

imgur_client.upload_from_path(event.pathname, config={"album":"azXrnwH"}, anon=False) 

the following exception results:


 File "imgupload.py", line 25, in ........
    imgur_client.upload_from_path(event.pathname, config={"album":"azXrnwH"}, anon=False)
  File "/root/.pyenv/versions/3.6.0/lib/python3.6/site-packages/imgurpython/client.py", line 596, in upload_from_path
    return self.make_request('POST', 'upload', data, anon)
  File "/root/.pyenv/versions/3.6.0/lib/python3.6/site-packages/imgurpython/client.py", line 161, in make_request
    raise ImgurClientError(response_data['data']['error'], response.status_code)
imgurpython.helpers.error.ImgurClientError: (500) {'code': 1001, 'message': 'File was not uploaded correctly', 'type': 'Exception_Logged', 'exception': {}}

Is there a way to get more information about this error?

void4 commented 6 years ago

It seems that the file was not fully written when I wanted to upload it. Waiting a few milliseconds before the upload fixed it.