gpt4 book ai didi

python - 将 GAE BlobInfo 转换为文件对象

转载 作者:太空宇宙 更新时间:2023-11-04 03:49:42 25 4
gpt4 key购买 nike

如何将 Google App Engine BlobInfo 对象转换为类文件对象以传递到 Google Cloud Storage?

最佳答案

我认为没有直接转换的机制。

您需要使用BlobReader 打开blob 并将其写入cloudstorage。

像这样:

blob_reader = BlobReader(blob_info.key())
data = blob_reader.read()
filename = '/yourbucket/your_file_filename'
with cloudstorage.open(filename, 'w') as f:
f.write(data)

Cloudstorage 是 gcs client library

This question如果您需要迁移大量数据,可能会有所帮助。

关于python - 将 GAE BlobInfo 转换为文件对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21891464/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com