def _save_directory(self, path, model):
"""Creates a directory in GCS."""
exists, obj = self._fetch(path)
if exists:
if isinstance(obj, Blob):
raise web.HTTPError(400, u"Not a directory: %s" % path)
else:
self.log.debug("Directory %r already exists", path)
return
bucket_name, bucket_path = self._parse_path(path)
if bucket_path == "":
self.client.create_bucket(bucket_name)
else:
bucket = self._get_bucket(bucket_name, throw=True)
bucket.blob(bucket_path).upload_from_string(
b"", content_type="application/x-directory")
评论列表
文章目录