Google appengine的webapp2具有非常神秘的documentation regarding the handling of uploaded files。
Uploaded files are available as cgi.FieldStorage (see the cgi module) instances directly in request.POST.
我有一个表单,该表单对要存储在NDB.JsonProperty中的JSON文件发出POST请求。
谁能提供一个简短的示例说明我如何从请求对象中读取文件?
最佳答案
您可以在表单中使用enctype="multipart/form-data"
,然后在处理程序中使用来获取文件内容:
raw_file = self.request.get('field_name')
然后,将raw_file作为输入传递到模型的属性。