无法在POST请求中获取base64数据

时间:2017-09-26 13:54:06

标签: django django-rest-framework http-post cropperjs

从POST请求中读取数据时遇到了麻烦。

Request screenshot

从前端看来一切都很好,但是当我什么都没得到的时候  当试图在后端读取请求数据时。

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 call的选项

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()
    },
   }

我完全是空白,任何帮助都将不胜感激。

0 个答案:

没有答案