Skip to content

Instantly share code, notes, and snippets.

@xiaodongliang
Created February 5, 2015 09:14
Show Gist options
  • Select an option

  • Save xiaodongliang/cd1d6b69feb417e9e2fe to your computer and use it in GitHub Desktop.

Select an option

Save xiaodongliang/cd1d6b69feb417e9e2fe to your computer and use it in GitHub Desktop.
url = BASE_URL + 'viewingservice/v1/thumbnails'
url = url + '/' + urn
headers = {
'Authorization' : 'Bearer ' + access_token
}
print url
print headers
#execute the http request
r = requests.get(url,headers=headers,stream=True)
if r.status_code == 200:
with open("c:\\temp\\mythumnail.png", 'wb') as f:
for chunk in r.iter_content():
f.write(chunk)
if verbose or 200 != r.status_code:
print r.status_code
print r.headers['content-type']
print r.content
if 200 != r.status_code:
print "Get thumnail returned status code %s." % r.status_code
raise SystemExit(9)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment