angularjs - How to send binary data to API with Angular js -


i trying send image binary api.

the api has mode can send url, if code works fine. want send binary image html canvas. here's docs of api can see parameter https://dev.havenondemand.com/apis/ocrdocument#request

i error alert when call getocr method. leads me think api call isnt being made correctly. pls help.

here's send function looks like.

$scope.getocr = function(imagedata){     var apikey = 'xxxxxx';     var requeststring = 'https://api.havenondemand.com/1/api/sync/ocrdocument/v1?apikey='+ apikey +'&file='+ "data:image/jpeg;base64," + imagedata;      $http.get(requeststring).then(function(resp) {         alert(angular.fromjson(resp.data).text_block[0]['text']);         }, function(err) {             alert('error');           }) } 

and here's looks when call method

$cordovacamera.getpicture(options).then(function(imagedata) {         $scope.imguri = "data:image/jpeg;base64," + imagedata;          $scope.getocr(imagedata);      },     function(err) {         // error occured. show message user     }); 

well, first off, looks you're adding data:image/jpeg;base64 prefix twice. once in getpicture(options).then(), when construct request url. use browser dev tools inspect request , verify it's expect.

edit: looks api may expecting post request image data multipart form data? not entirely sure, documentation doesn't seem complete.


Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

c - Unrecognised emulation mode: elf_i386 on MinGW32 -