I tried to use POST to send some bytes using ArrayBuffer
, but it seems that the request payload is always empty. Here's some code snippet:
var buffer = new ArrayBuffer(10);
var dataView = new DataView(buffer);
dataView.setInt32(0, 0x1234ABCD);
var request = {
method: 'POST',
url: 'url',
headers: {'Content-Type': 'application/octet-stream'},
data: buffer,
responseType: 'arraybuffer'
};
$http(request)
.success(function(data, status, headers, config) { ... })
.error(function(data, status, headers, config) { ... });
As I commented, to send ArrayBuffer, you need to use XHR2 directly (seems AngularJs doesn't support it). Here's some code of how to do it:
More details about XHR2: http://www.html5rocks.com/en/tutorials/file/xhr2/#toc-send-string, hope this could help for someone who's also puzzled :)