Decode an App Engine Blobkey to a Google Cloud Storage Filename

前端 未结 3 2029
野趣味
野趣味 2021-02-13 22:38

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

相关标签:
3条回答
  • 2021-02-13 23:11

    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?

    0 讨论(0)
  • 2021-02-13 23:15

    If you have blobKeys you can use: ImagesServiceFactory.makeImageFromBlob

    0 讨论(0)
  • 2021-02-13 23:18

    From the statement in the docs, it looks like the generated GCS filenames are lost. You'll have to use gsutil to manually browse your bucket.

    https://developers.google.com/storage/docs/gsutil/commands/ls

    0 讨论(0)
提交回复
热议问题