python - 在 Google Cloud Storage 中以编程方式创建和删除存储桶

标签 python google-app-engine google-cloud-storage bucket

我正在使用 Google App Engine 和 Google Cloud Storage。我想使用 cron 作业每天创建一个存储桶。另外,以编程方式删除存储桶。我能够使用 Google Cloud Console 手动创建存储桶。

如何使用 python 从 GAE 创建/删除存储桶?

另外,每天创建一个新的桶是一个好的设计选择吗?

注意:我是 Google Cloud Storage 的新手。

最佳答案

每天创建一个新存储桶可能不是最好的主意。它没有太大的危害,但也没有任何优势,因为单个桶可以增长到您可能需要的大小。对于逻辑上不同类型的数据使用不同的存储桶通常是一个更好的主意。

至于如何做到这一点,答案取决于您使用的库。一个不错的选择是 gcloud-python 。使用该库:

from gcloud import storage
client = storage.Client()
client.create_bucket("BucketName")

关于python - 在 Google Cloud Storage 中以编程方式创建和删除存储桶,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38319785/

相关文章:

python-3.x - 在 Google App Engine 上按计划运行 python 脚本

java - 在实现 GCS 时,在 gradle android 中添加实现 'com.google.cloud:google-cloud-storage' 后,重复类发现错误

python - Pandas to_csv() 保存大数据帧速​​度慢

python - 如何将 st.columns 与 st.tabs (Streamlit) 一起使用

python - 如何获得每个边界点与霍夫线之间的垂直距离?

python - matplotlib 中是否有最大 figsize?

google-app-engine - Go:如何将 struct 转换为 []byte?

java - 使用 int 调用 setProperty 但 getProperty 返回 Long on google app engine persistent storage

python - 如何迭代谷歌云存储中的所有文件以用作数据流输入?

python - 从 Python 中的 download_as_string 访问 blob 对象中的数据