使用 EVE API 框架 return 最大递归错误将媒体文件列表上传到 Mongodb
Upload LIST of Media files to Mongodb using EVE API framework return maximum recursion Error
我启动了 EVE 并 运行 并根据 docs:
定义了我的模式
accounts = {
'name': {'type': 'string'},
'multimedia': {'type': 'media'}
}
我可以发送带有一个文件的 multipart/form-data 请求,但我想发送 LIST 媒体文件。我已经按照文档进行操作并添加了以下设置:
# This flag allows passthrough from the driver of additional meta fields.
# For example, using the MongoDB driver, fields like content_type, name and
# length can be added to this list and will be passed-through from the
# underlying driver.When EXTENDED_MEDIA_INFO is used the field will be a
# dictionary whereas the file itself is stored under the file key and other
# keys are the meta fields.
EXTENDED_MEDIA_INFO = ['content_type', 'name', 'length']
# For multipart/form-data uploads to treat the incoming fields as JSON encoded strings
# and still be able to validate your fields.
MULTIPART_FORM_FIELDS_AS_JSON = True
# When using lists of media, there is no way to submit these in the default configuration.
# Enable AUTO_COLLAPSE_MULTI_KEYS and AUTO_CREATE_LISTS to make this possible. This allows
# to send multiple values for one key in multipart/form-data requests and in this way upload
# a list of files.
AUTO_COLLAPSE_MULTI_KEYS = True
AUTO_CREATE_LISTS = True
现在我尝试发送多个文件时出现以下错误:
{
"status": "ERR",
"error": {
"code": 400,
"message": "An exception occurred: maximum recursion depth exceeded while calling a Python
object"
}
}
有什么建议吗?我用这个片段来测试:
curl -X PATCH -H "Authorization: Bearer g6SZBmknNLf401915dNSJi4WNK72pk"
-H "Content-Type: multipart/form-data"
-F "multimedia=@text.json" -F "mutlimedia=@event.json"
http://localhost:5000/endpoint/_id
{"status": "ERR", "error": {"code": 400, "message": "An exception occurred:
maximum recursion depth exceeded while calling a Python object"}}
夏娃日志:
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/eve/methods/patch.py", line
244, in patch_internal issues = validator.errors
File "/usr/local/lib/python3.7/site-packages/cerberus/validator.py", line
464, in errors return self.error_handler(self._errors)
File "/usr/local/lib/python3.7/site-packages/cerberus/errors.py", line
493, in __call__self.extend(errors)
File "/usr/local/lib/python3.7/site-packages/cerberus/errors.py", line
397, in extend self.add(error)
File "/usr/local/lib/python3.7/site-packages/cerberus/errors.py", line
510, in add error = deepcopy(error)
File "/usr/local/lib/python3.7/copy.py", line 180, in deepcopy
y = _reconstruct(x, memo, *rv)
File "/usr/local/lib/python3.7/copy.py", line 280, in _reconstruct
state = deepcopy(state, memo)
File "/usr/local/lib/python3.7/copy.py", line 150, in deepcopy
y = copier(x, memo)
File "/usr/local/lib/python3.7/copy.py", line 240, in _deepcopy_dict
y[deepcopy(key, memo)] = deepcopy(value, memo)
File "/usr/local/lib/python3.7/copy.py", line 180, in deepcopy
y = _reconstruct(x, memo, *rv)
File "/usr/local/lib/python3.7/copy.py", line 281, in _reconstruct
if hasattr(y, '__setstate__'):
File "/usr/local/lib/python3.7/site-packages/werkzeug/datastructures.py",
line 2821, in __getattr__return getattr(self.stream, name)
File "/usr/local/lib/python3.7/site-packages/werkzeug/datastructures.py",
line 2821, in __getattr__return getattr(self.stream, name)
File "/usr/local/lib/python3.7/site-packages/werkzeug/datastructures.py",
line 2821, in __getattr__return getattr(self.stream, name)
[Previous line repeated 485 more times]
RecursionError: maximum recursion depth exceeded while calling a Python
object
问题已提交给 Eve 项目 Github repo。
我关注了该功能的 PR,现在它的效果很好! https://github.com/pyeve/eve/pull/933
我启动了 EVE 并 运行 并根据 docs:
定义了我的模式accounts = {
'name': {'type': 'string'},
'multimedia': {'type': 'media'}
}
我可以发送带有一个文件的 multipart/form-data 请求,但我想发送 LIST 媒体文件。我已经按照文档进行操作并添加了以下设置:
# This flag allows passthrough from the driver of additional meta fields.
# For example, using the MongoDB driver, fields like content_type, name and
# length can be added to this list and will be passed-through from the
# underlying driver.When EXTENDED_MEDIA_INFO is used the field will be a
# dictionary whereas the file itself is stored under the file key and other
# keys are the meta fields.
EXTENDED_MEDIA_INFO = ['content_type', 'name', 'length']
# For multipart/form-data uploads to treat the incoming fields as JSON encoded strings
# and still be able to validate your fields.
MULTIPART_FORM_FIELDS_AS_JSON = True
# When using lists of media, there is no way to submit these in the default configuration.
# Enable AUTO_COLLAPSE_MULTI_KEYS and AUTO_CREATE_LISTS to make this possible. This allows
# to send multiple values for one key in multipart/form-data requests and in this way upload
# a list of files.
AUTO_COLLAPSE_MULTI_KEYS = True
AUTO_CREATE_LISTS = True
现在我尝试发送多个文件时出现以下错误:
{
"status": "ERR",
"error": {
"code": 400,
"message": "An exception occurred: maximum recursion depth exceeded while calling a Python
object"
}
}
有什么建议吗?我用这个片段来测试:
curl -X PATCH -H "Authorization: Bearer g6SZBmknNLf401915dNSJi4WNK72pk"
-H "Content-Type: multipart/form-data"
-F "multimedia=@text.json" -F "mutlimedia=@event.json"
http://localhost:5000/endpoint/_id
{"status": "ERR", "error": {"code": 400, "message": "An exception occurred:
maximum recursion depth exceeded while calling a Python object"}}
夏娃日志:
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/eve/methods/patch.py", line
244, in patch_internal issues = validator.errors
File "/usr/local/lib/python3.7/site-packages/cerberus/validator.py", line
464, in errors return self.error_handler(self._errors)
File "/usr/local/lib/python3.7/site-packages/cerberus/errors.py", line
493, in __call__self.extend(errors)
File "/usr/local/lib/python3.7/site-packages/cerberus/errors.py", line
397, in extend self.add(error)
File "/usr/local/lib/python3.7/site-packages/cerberus/errors.py", line
510, in add error = deepcopy(error)
File "/usr/local/lib/python3.7/copy.py", line 180, in deepcopy
y = _reconstruct(x, memo, *rv)
File "/usr/local/lib/python3.7/copy.py", line 280, in _reconstruct
state = deepcopy(state, memo)
File "/usr/local/lib/python3.7/copy.py", line 150, in deepcopy
y = copier(x, memo)
File "/usr/local/lib/python3.7/copy.py", line 240, in _deepcopy_dict
y[deepcopy(key, memo)] = deepcopy(value, memo)
File "/usr/local/lib/python3.7/copy.py", line 180, in deepcopy
y = _reconstruct(x, memo, *rv)
File "/usr/local/lib/python3.7/copy.py", line 281, in _reconstruct
if hasattr(y, '__setstate__'):
File "/usr/local/lib/python3.7/site-packages/werkzeug/datastructures.py",
line 2821, in __getattr__return getattr(self.stream, name)
File "/usr/local/lib/python3.7/site-packages/werkzeug/datastructures.py",
line 2821, in __getattr__return getattr(self.stream, name)
File "/usr/local/lib/python3.7/site-packages/werkzeug/datastructures.py",
line 2821, in __getattr__return getattr(self.stream, name)
[Previous line repeated 485 more times]
RecursionError: maximum recursion depth exceeded while calling a Python
object
问题已提交给 Eve 项目 Github repo。
我关注了该功能的 PR,现在它的效果很好! https://github.com/pyeve/eve/pull/933