Reputation: 3202
I recently noticed that in the 1.8.1 App Engine release they changed the status from "experimental" to "deprecated" of the file-like API for Py 2.7 runtime Blobstore. Looking over the docs, it would seem they don't have a file-like context manager for Cloud File Storage. Has anyone migrated their Blobstorage to GCS API? Any tips and advice are greatly appreciated.
Upvotes: 1
Views: 138
Reputation: 2265
Appengine-gcs-client allows you to use gcs from appengine in much the same was as old files api. I'm not sure why it's not made more prominent in the documentation.
Here's a snippet from the demo
def create_file(self, filename):
"""Create a file.
The retry_params specified in the open call will override the default
retry params for this particular file handle.
Args:
filename: filename.
"""
self.response.write('Creating file %s\n' % filename)
write_retry_params = gcs.RetryParams(backoff_factor=1.1)
gcs_file = gcs.open(filename,
'w',
content_type='text/plain',
options={'x-goog-meta-foo': 'foo',
'x-goog-meta-bar': 'bar'},
retry_params=write_retry_params)
gcs_file.write('abcde\n')
gcs_file.write('f'*1024*1024 + '\n')
gcs_file.close()
self.tmp_filenames_to_clean_up.append(filename)
Edit: It's in the docs: https://developers.google.com/appengine/docs/python/googlecloudstorageclient/#about_the_google_cloud_storage_gcs_client_library
Upvotes: 1