def upload_file(file_stream, filename, content_type):
    _check_extension(filename, current_app.config['ALLOWED_EXTENSIONS'])
    filename = _safe_filename(filename)

    client = _get_storage_client()
    bucket = client.get_bucket(current_app.config['CLOUD_STORAGE_BUCKET'])
    blob = bucket.blob(filename)

    blob.upload_from_string(
        file_stream,
        content_type=content_type)

    url = blob.public_url

    if isinstance(url, six.binary_type):
        url = url.decode('utf-8')

    return url
# [END upload_file]
Uploads a file to a given Cloud Storage bucket and returns the public url
dataset/ETHPy150Open GoogleCloudPlatform/getting-started-python/3-binary-data/bookshelf/storage.py/upload_file