@run_if('GOOGLE_APPS')
def add_image(service, folder_id, url):

    response = requests.get(url, stream=True)
    if response.status_code != 200:
        raise FailedRequest('Unable to successfully retrieve '
                            'an image: %s', (url))

    temp = tempfile.NamedTemporaryFile(mode='wb', delete=False)
    for chunk in response.iter_content(1024):
        temp.write(chunk)

    title_regex = image_file_regex.search(response.url)
    if title_regex is None:
        raise InvalidUrlError('Url is not for an image.')

    title = title_regex.group()
    mimetype = _get_image_mimetype(response, title)
    temp.close()
    google_image = service.insert_file(title,
                                       'image',
                                       folder_id,
                                       mimetype,
                                       temp.name)
    os.unlink(temp.name)
    return google_image
Add image to a folder.
dataset/ETHPy150Open unlimitedlabs/orchestra/orchestra/google_apps/convenience.py/add_image