0

I am using angular js to make POST request to API. I need to send some headers and audio file with it. I have written sample code for the same in controller.

    $scope.files='bostonSeltics.wav';
    $scope.getText = function (access_token) {$http({method:'POST',
    url:'https://api.att.com/rest/1/SpeechToText',      
    headers:{
    'Accept':'application/json',
    'Authorization':'Bearer '+access_token,
    'X-SpeechContext': 'Generic',
    'Content-Type':'audio/wav'},
    data:$scope.files}).success(function(response){
    ......
      }).error(function(error){
    ......
    });

I just wanted to know whether this correct method to send audio data or not.

Thanks in advance.

Regards, Mohan

SavantMohan
  • 35
  • 2
  • 9

1 Answers1

0

use angular js file upload directive its make easy to upload than http..ng-file upload and i would better if you can write with inside a factory and it will improve reusability