Skip to content

Instantly share code, notes, and snippets.

@roycrxtw
Created July 21, 2019 04:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save roycrxtw/de3b0f6570ef61fbd86f4d1e497bd205 to your computer and use it in GitHub Desktop.
Save roycrxtw/de3b0f6570ef61fbd86f4d1e497bd205 to your computer and use it in GitHub Desktop.
def uploadImage():
with open("temp.jpg", "rb") as fs:
binary_data = fs.read()
url = 'https://api.imgur.com/3/image'
payload = {'image': binary_data}
files = {}
headers = {
'Authorization': 'Client-ID ' + client_id
}
response = requests.request('POST', url, headers = headers, data = payload, files = files, allow_redirects = False, timeout = 10000)
print(response.text)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment