来自使用blobstore.create_gs_key创建的BlobKey的BlobInfo对象 [英] BlobInfo object from a BlobKey created using blobstore.create_gs_key

查看:141
本文介绍了来自使用blobstore.create_gs_key创建的BlobKey的BlobInfo对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将代码从弃用的文件api转换而来。

I am converting code away from the deprecated files api.

我有以下代码在SDK服务器中正常工作,但生产失败。我所做的甚至是正确的?如果是的话,那么可能会出现什么错误,如何排除故障?

I have the following code that works fine in the SDK server but fails in production. Is what I am doing even correct? If yes what could be wrong, any ideas how to troubleshoot it?

# 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对象。

Unfortunately, as per the documentation, you can't get a BlobInfo object for GCS files.

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


注意:获得GCS对象的blobKey后,您可以将它传递,序列化并以其他方式交替使用,只要您可以将blobKey用于存储在Blobstor中的对象即这允许应用程序在应用程序中将一些数据存储在blobstore中,另一些则存储在GCS中,但在其他应用程序中以其他方式处理数据。 (但是,BlobInfo对象目前不适用于GCS对象。)

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.)

这篇关于来自使用blobstore.create_gs_key创建的BlobKey的BlobInfo对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆