Hello Every one I have a problem.
I want to create file upload function in the class but the service request error message is “POST http://localhost:8000/eventfile/ 400 (Bad Request)” and “"Multipart form parse error - Invalid boundary in multipart: None””.source code:
1.Django Serviceclass EventFileAPI(APIView):
def post(self, request, format=None):
print(self.request.data)
return HttpResponse(JsonResponse({'event_data':'ok'}), content_type='application/json')
2.Front-End&AngularJSHTML
...
<input type="file" file-model="myFile"/>
<button ng-click="uploadFile()">upload me</button>
...
angularjs
...
$
http.post(uploadUrl, file, {
transformRequest: angular.identity,
headers: {
'Content-Type': 'multipart/form-data',
'Authorization': 'JWT '+$window.sessionStorage.getItem('accessToken')
}
})
...