Reputation: 1665
blobstore.parse_file_info(cgi.FieldStorage()['file']) method doesn't work for BlobstoreUploadHandler, the FieldStorage seems to be for regular uploads
There is no gcs filename information inside the blob_info that the regular blob_info from self.get_uploads provides
It seems only a blob_key can be accessed using the regular methods, however a gcs file_name seems to be the safest bet for future
How can I get gcs file_name of a file uploaded to an url from blobstore.create_upload_url with gs_bucket_name argument?
Upvotes: 4
Views: 1443
Reputation: 6627
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 did find the usage in code, but I cannot find document either.
In https://developers.google.com/appengine/docs/python/blobstore/fileinfoclass said.
If you're using the webapp or webapp2 application framework, you can use the BlobstoreUploadHandler for more convenient parsing of this information.
But there is nothing related to FileInfo
I can find in document of BlobstoreUploadHandler
https://developers.google.com/appengine/docs/python/tools/webapp/blobstorehandlers
Upvotes: 5