尝试使用blobstore将图像上传到google app引擎项目时出现以下错误:
POST someindex/_search
{
"size":0,
"aggs":{
"myagg":{
"terms":{
"script":{
"source":"doc['field1'].value + params.param + doc['field2'].value + params.param + doc['field3'].value",
"lang":"painless",
"params":{
"param":", "
}
},
"order":{
"_term":"asc"
}
}
}
}
}
我的代码如下:
ERROR 2018-10-29 11:18:21,519 user.py:476] ERROR is 'PicUploadHandler'
object has no attribute '_BlobstoreUploadHandler__uploads'
ERROR 2018-10-29 11:18:21,519 user.py:477] EXC is 'PicUploadHandler'
object has no attribute '_BlobstoreUploadHandler__uploads'
Traceback (most recent call last):
File "C:\Users\...\PycharmProjects\...\user.py", line 460, in post
upload_files = self.get_uploads()[0] #: 'file' is file upload field in
the form
File "C:\Program Files(x86)\Google\google_appengine\google\appengine\ext\webapp\blobstore_handlers.py", line 380, in get_uploads
if self.__uploads is None:
AttributeError: 'PicUploadHandler' object has no attribute '_BlobstoreUploadHandler__uploads'
我已经从一个较旧的项目中复制并粘贴了此代码,该项目在其中没有错误地运行。
非常感谢您的帮助。
编辑: 作为冰雹玛丽,我上传了代码,以便检查实时实例中的日志。看来问题出在开发服务器/数据存储上,因为该代码在应用在线时运行。有人知道为什么会这样吗?
答案 0 :(得分:0)
尝试登录以查看所拥有的内容
import logging
user = self.user_obj()
if user:
self.response.headers['Content-Type'] = 'image/svg+xml'
if user.pic_key:
blobstore.delete(user.pic_key) #: retrieve the old home photo and delete it
logging.error(self.get_uploads())
logging.error(self.get_uploads()[0])
upload_files = self.get_uploads()[0] #: 'file' is file upload field in the form
...