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

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

问题描述

我有一个数据库,其中包含以前通过标准 Google App Engine 上传的 BlobKeys create_upload_url() 过程,通过设置 gs_bucket_name 参数,每个上传都进入同一个 Google Cloud Storage 存储桶.

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.

我想做的是能够解码现有的 blobkey,以便获取它们的 Google Cloud Storage 文件名.我了解我可以一直在使用 FileInfo 类gs_object_name 属性>,除了:

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:

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

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.

意思是 gs_object_name 属性仅在上传处理程序中可用,如果我当时没有保存它,那么它就丢失了.

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.

此外,create_gs_key() 不会执行技巧,因为它取而代之的是一个 google 存储文件名并创建一个 blobkey.

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

那么,如何获取之前通过应用引擎上传到 Google Cloud Storage 存储桶的 blobkey,并获取它的 Google Cloud Storage 文件名?(蟒蛇)

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)

推荐答案

您只能在上传处理程序(fileInfo.gs_object_name)中获取cloudstorage文件名并将其存储在您的数据库中.之后它就丢失了,并且似乎没有保存在 BlobInfo 或其他元数据结构中.

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 说:不像 BlobInfo 元数据 FileInfo 元数据不是持久化到数据存储区.(也没有 blob 键,但你可以如果需要,稍后通过调用 create_gs_key 创建一个.)您必须保存上传处理程序中的 gs_object_name 或此数据将迷路了.

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/文件信息类

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

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 说:将加密的 blob 密钥作为字符串返回."有谁知道为什么这是加密的?

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 Cloud Storage 文件名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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