How to get FileInfo / gcs filename for files uploaded via BlobstoreUploadHandler?

blobstore.parse_file_info (cgi.FieldStorage () ['file']) method does not work for BlobstoreUploadHandler, FieldStorage seems to be for regular downloads

Inside blob_info there is no information about the name of the gcs file, in which the usual blob_info from self.get_uploads provides

It seems that blob_key can be accessed using the usual methods, however gcs file_name seems to be the safest bet for the future

How can I get gcs filename of a file uploaded to url from blobstore.create_upload_url with argument gs_bucket_name?

+4
source share
1 answer
class UploadAPI(blobstore_handlers.BlobstoreUploadHandler): def post(self): file_info = self.get_file_infos()[0] rtn_data = { "filename": file_info.filename, "content_type": file_info.content_type, "creation": file_info.creation, "size": file_info.size, "md5_hash": file_info.md5_hash, "gs_object_name": file_info.gs_object_name } 

I found use in the code, but I also can not find the document.

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

If you use the webapp or webapp2 application platform, you can use the BlobstoreUploadHandler to more conveniently analyze this information.

But nothing has to do with FileInfo , which can be found in the BlobstoreUploadHandler document https://developers.google.com/appengine/docs/python/tools/webapp/blobstorehandlers

+5
source

All Articles