从 POST 请求中读取数据时遇到问题。
从前端看来一切都很好,但是当我尝试读取后端的请求数据时什么也没得到。
request.FILES
<MultiValueDict: {}>
request.POST
<QueryDict: {}>
request.body
*** RawPostDataException: You cannot access body after reading from request's data stream
后端查看代码
def upload_file(request):
upload_response = requests.post(requestbuilder.create_request('/files'), files={request.FILES['file']._name:request.FILES['file']}, headers=requestbuilder.MULTIPART_HEADERS)
return HttpResponse(upload_response.json().get('fileUrl'))
ajax 调用的选项
var options = {
url: "/apps/upload/",
method: 'post',
addRemoveLinks: true,
clickable: false,
maxFiles: config.maxFiles,
minWidth: config.minWidth,
minHeight: config.minHeight,
headers: {
'X-CSRFToken': $("input[name=csrfmiddlewaretoken]").val()
},
}
我完全空白,任何帮助将不胜感激。