Why do I need to use the Upload service with ng-file-upload in this specific way?
Upload.upload({
url: '/postMyFormHere',
data: {
fileToUpload: model.file,
someField1: model.field1,
someField2: model.field2,
}
})
Can't I just simplify it like this?
$http({
method: 'post',
headers: {
'content-type': 'multipart/form-data'},
url: '/postMyFormHere',
data: {
fileToUpload: model.file,
someField1: model.field1,
someField2: model.field2,
}
})
I thought ng-file-upload was just for binding files from inputs to the model. Shouldn't Angular be able to handle a multipart/form-data POST request natively?
Edit:
I've been attempting to make my multipart post work through $http. I modified the header to:
"multipart/form-data; boundary=----WebKitFormBoundarypEvyJj8BAuq4lk7T"
But I encountered this error on my express server
Error: Multipart: Boundary not found
I assume that the purpose of the Upload service is to parse the POST payload with the multipart boundary correctly, right?