gpt4 book ai didi

python - 来自使用 blobstore.create_gs_key 创建的 BlobKey 的 BlobInfo 对象

转载 作者:太空狗 更新时间:2023-10-30 02:20:58 27 4
gpt4 key购买 nike

我正在从已弃用的文件 API 中转换代码。

我有以下代码在 SDK 服务器中运行良好但在生产环境中失败。我在做什么是正确的吗?如果是,可能出了什么问题,有什么解决方法吗?

# Code earlier writes the file bs_file_name. This works fine because I can see the file
# in the Cloud Console.
bk = blobstore.create_gs_key( "/gs" + bs_file_name)
assert(bk)
if not isinstance(bk,blobstore.BlobKey):
bk = blobstore.BlobKey(bk)
assert isinstance(bk,blobstore.BlobKey)
# next line fails here in production only
assert(blobstore.get(bk)) # <----------- blobstore.get(bk) returns None

最佳答案

很遗憾,根据文档,您无法获取 GCS 文件的 BlobInfo 对象。

https://developers.google.com/appengine/docs/python/blobstore/#Python_Using_the_Blobstore_API_with_Google_Cloud_Storage

Note: Once you obtain a blobKey for the GCS object, you can pass it around, serialize it, and otherwise use it interchangeably anywhere you can use a blobKey for objects stored in Blobstore. This allows for usage where an app stores some data in blobstore and some in GCS, but treats the data otherwise identically by the rest of the app. (However, BlobInfo objects are currently not available for GCS objects.)

关于python - 来自使用 blobstore.create_gs_key 创建的 BlobKey 的 BlobInfo 对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19287709/

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