class UploadHandler(blobstore_handlers.BlobstoreUploadHandler):
def post(self):
reseller_id = self.request.get('reseller_id')
upload_files = self.request.get('logo_img')
if upload_files:
blob_info = upload_files[0]
key = blob_info.key()
我在第
行收到错误key = blob_info.key()
错误:
AttributeError: 'str' object has no attribute 'key
事情是文件上传正确,我可以在GAE blob查看器中看到它。我从上传示例中复制了此代码:
https://developers.google.com/appengine/docs/python/blobstore/overview#Complete_Sample_App
我不知道为什么我没有通过使用blob_info.key()来获取键值。欢迎使用任何指针。
答案 0 :(得分:2)
请注意,在他们的示例中:
upload_files = self.get_uploads('file') # 'file' is file upload field in the form
在您的示例中,upload_files是用户为logo_img字段设置的值,该字段是一个字符串。
我认为logo_img字段是用户上传的文件,因此您需要改为
upload_files = self.get_uploads('logo_img')