Here is an example:
def gcs_write_blob(dyn, blob):
""" update google cloud storage dyn entity """
gcs_file_name = '/%s/%s' % (default_bucket, dyn.filename)
content_type = mimetypes.guess_type(dyn.filename)[0]
if dyn.extension in ['js', 'css']:
content_type += b'; charset=utf-8'
with gcs.open(gcs_file_name, 'w', content_type=content_type,
options={b'x-goog-acl': b'public-read'}) as f:
f.write(blob)
return gcs_file_name
Taken from this gist: https://gist.github.com/voscausa/9541133