in optional-kubernetes-engine/bookshelf/tasks.py [0:0]
def download_and_upload_image(src, dst_filename):
"""
Downloads an image file and then uploads it to Google Cloud Storage,
essentially re-hosting the image in GCS. Returns the public URL of the
image in GCS
"""
r = requests.get(src)
if not r.status_code == 200:
return
return storage.upload_file(
r.content,
dst_filename,
r.headers.get('content-type', 'image/jpeg'))