【发布时间】:2019-02-19 14:39:54
【问题描述】:
我们正在使用 GCS(谷歌云存储),我想知道https://cloud.google.com/appengine/docs/standard/python/googlecloudstorageclient/read-write-to-cloud-storage 中描述的方法是否会在操作期间锁定文件以防止其他访问它的东西?
我是新手,目前我发现的第一个方法是在import cloudstorage as gcs中使用下载和上传作为字符串函数
喜欢...
current_details = json.loads(device_blob.download_as_string().decode('utf-8'))
LOGGER.info(current_details)
current_details.update(details)
device_blob.upload_from_string(json.dumps(current_details))
但很明显,在下载和上传调用之间,其他东西可能会修改文件。
所以如果import cloudstorage as gcs 是要走的路,请告诉我。
谢谢!
【问题讨论】:
-
“如果导入
cloudstorage as gcs是要走的路”是什么意思? -
如果使用打开/关闭锁定文件,使其他服务无法访问它,直到它被关闭。
标签: python-3.x google-cloud-platform google-cloud-storage