Sending a binary file through http?

Hi All,

I want to send a binary file to a server through $http.post. I have no idea how to do this because the $http processes my data to JSON?

if you are using this in mobile-app context you need the cordova-file-transfer plugin
and in an angularjs webapp you can set $http content type --> and send your file with an ordinary FormData-file field

Look here:

the part with the caption: Making the multipart/form-data request

You can reset the contenttype header with:

headers: {'Content-Type': undefined} // so the browser sets the correct type

and

transformRequest: angular.identity // reset the request data transformation (no json en/decoding)
1 Like