I'm working on a web-app where a feature is to open a file on the server through a webservice. I am working with Angular 1.5 and use ng-file-upload to upload all my files.
Here is the code I'm using:
Template:
<input type="file" ngf-select ng-model="temp_report.report" />
Controller:
// Temporary object which will store the File object
$scope.temp_report = {
report: null
}
// Function called on click button
$scope.saveAuditorReport = function () {
console.log($scope.temp_report.report);
// Call to Service
Audit.addAuditReport($scope.temp_report).then(
function (resp) {
console.log(resp);
}, function (resp) {
console.log(resp);
}
);
}
The console.log
returns the File object. Everything is good.
And now, here is a part of the service:
this.addAuditReport = function (report) {
console.log(report);
return $http.put($rootScope.API_URL + '/audits/1/auditors/23928', {auditor: report});
}
The console.log
is well returning the File object, so, everything is good too.
But on the PUT
request, I don't understand anything. If I look the Chrome developer console, the sent request contains this:
auditor: {
report: {}
}
My report
object is now empty and I do not know what is happening. Does anyone have ever seen this?
Feel free to ask questions if I'm not giving every information I can. I will update them.