asterisk / node-ari-client

Node.js client for ARI. This library is best effort with limited support.
Other
250 stars 98 forks source link

getStoredFile() fails #62

Closed mpotra closed 7 years ago

mpotra commented 7 years ago

Description:

Asterisk 14 introduces the ability to fetch a recording file, which is transmitted in binary.

The getStoredFile() method fails with the following error:

RIFFd` ^

SyntaxError: Unexpected token R in JSON at position 0 at Object.parse (native) at SwaggerRequest.processResponse (/myapp/node_modules/ari-client/lib/client.js:261:31) at Object.response (/myapp/node_modules/swagger-client/lib/swagger.js:1086:24) at EventEmitter.response (/myapp/node_modules/swagger-client/lib/swagger.js:1308:19) at emitOne (events.js:96:13) at EventEmitter.emit (events.js:188:7) at emit (/myapp/node_modules/shred/lib/shred/request.js:456:21) at /myapp/node_modules/shred/lib/shred/request.js:476:9 at setBodyAndFinish (/myapp/node_modules/shred/lib/shred/response.js:103:7) at IncomingMessage. (/myapp/node_modules/shred/lib/shred/response.js:120:7) at emitNone (events.js:91:20) at IncomingMessage.emit (events.js:185:7) at endReadableNT (_stream_readable.js:974:12) at _combinedTickCallback (internal/process/next_tick.js:74:11) at process._tickCallback (internal/process/next_tick.js:98:9)

I've tracked this error to JSON.parse(result) attempting to parse a non-JSON binary string, instead of handling the Buffer object.