将App Engine Blobkey解码为Google云端存储文件名 [英] Decode an App Engine Blobkey to a Google Cloud Storage Filename

查看:165
本文介绍了将App Engine Blobkey解码为Google云端存储文件名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个数据库充满BlobKeys,以前通过标准的Google App Engine上传 create_upload_url()过程,并通过设置 gs_bucket_name 参数将每个上传文件传送到同一Google云端存储分区。



我想要做的是能够解码现有的blobkeys,以便我可以获取他们的Google Cloud Storage文件名。我知道我 可以 使用 gs_object_name 属性来自 FileInfo类,除了:

lockquote

您必须自己将gs_object_name保存在您的上传处理程序或
中,这些数据将会丢失。 (GCS中对象的其他元数据自动存储在GCS中
,因此您无需将其保存在上传处理程序中。


含义 gs_object_name 属性仅在上传处理程序中可用,如果我当时没有保存它,则丢失它。



另外, create_gs_key()并没有做到这一点,因为它取代了谷歌存储文件名并创建了一个blobkey。



那么,我怎样才能把一个以前上传的blobkey Google云存储存储分区通过应用引擎,并获得它的Google云存储文件名?(python)

解决方案

您可以获取cloudstorage文件名只存在于上传处理程序(fileInfo.gs_object_name)中,并将其存储在数据库中。之后,它将丢失,并且似乎不会保留在BlobIn中fo或其他元数据结构。


Google表示:与BlobInfo元数据不同,FileInfo元数据不是
,而是坚持数据存储。 (也没有blob键,但如果需要,可以通过调用create_gs_key来
创建一个。)必须将
gs_object_name自己保存到上传处理程序中,否则这些数据将会丢失


https://developers.google.com/appengine/docs/python/blobstore/fileinfoclass



更新:我能够解码Blobstore-Viewer中的SDK-BlobKey:encoded_gs_file:base64-encoded-filename-here。然而,真实的东西不是base64编码的。



create_gs_key(文件名,rpc =无)... Google说:以字符串形式返回加密的blob密钥。有没有人猜测为什么这是加密的?

I've got a database full of BlobKeys that were previously uploaded through the standard Google App Engine create_upload_url() process, and each of the uploads went to the same Google Cloud Storage bucket by setting the gs_bucket_name argument.

What I'd like to do is be able to decode the existing blobkeys so I can get their Google Cloud Storage filenames. I understand that I could have been using the gs_object_name property from the FileInfo class, except:

You must save the gs_object_name yourself in your upload handler or this data will be lost. (The other metadata for the object in GCS is stored in GCS automatically, so you don't need to save that in your upload handler.

Meaning gs_object_name property is only available in the upload handler, and if I haven't been saving it at that time then its lost.

Also, create_gs_key() doesn't do the trick because it instead takes a google storage filename and creates a blobkey.

So, how can I take a blobkey that was previously uploaded to a Google Cloud Storage bucket through app engine, and get it's Google Cloud Storage filename? (python)

解决方案

You can get the cloudstorage filename only in the upload handler (fileInfo.gs_object_name) and store it in your database. After that it is lost and it seems not to be preserved in BlobInfo or other metadata structures.

Google says: Unlike BlobInfo metadata FileInfo metadata is not persisted to datastore. (There is no blob key either, but you can create one later if needed by calling create_gs_key.) You must save the gs_object_name yourself in your upload handler or this data will be lost.

https://developers.google.com/appengine/docs/python/blobstore/fileinfoclass

Update: I was able to decode a SDK-BlobKey in Blobstore-Viewer: "encoded_gs_file:base64-encoded-filename-here". However the real thing is not base64 encoded.

create_gs_key(filename, rpc=None) ... Google says: "Returns an encrypted blob key as a string." Does anyone have a guess why this is encrypted?

这篇关于将App Engine Blobkey解码为Google云端存储文件名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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