diff --git a/CHANGELOG.md b/CHANGELOG.md index ec229df..428fc13 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,6 @@ # Change Log +## [4.18.1](https://github.com/plivo/plivo-node/releases/tag/v4.18.1)(2021-06-25) +- Fixed the mms media upload functionality ## [4.18.0](https://github.com/plivo/plivo-node/releases/tag/v4.18.0)(2021-06-15) - Added stir verification param as part of Get CDR and live call APIs diff --git a/lib/resources/media.js b/lib/resources/media.js index ad027a7..aa229ed 100644 --- a/lib/resources/media.js +++ b/lib/resources/media.js @@ -97,7 +97,7 @@ export class MediaInterface extends PlivoResourceInterface { params.file = files let client = this[clientKey]; - + params.multipart = true; return new Promise((resolve, reject) => { client('POST', action, params) .then(response => { diff --git a/lib/rest/axios.js b/lib/rest/axios.js index 61f8cde..5316274 100644 --- a/lib/rest/axios.js +++ b/lib/rest/axios.js @@ -46,7 +46,14 @@ export function Axios(config) { if (key != 'file') { multipartParams.append(key, params[key]); } else { - multipartParams.append(key, require('fs').createReadStream(params[key])); + // In case files are in array + if (Array.isArray(params.file)) { + for (let index = 0; index < params.file.length; index++) { + multipartParams.append(key, require('fs').createReadStream(params.file[index])); + } + }else{ + multipartParams.append(key, require('fs').createReadStream(params[key])); + } } } @@ -87,6 +94,10 @@ export function Axios(config) { }); }) .catch(function (error) { + //client side exception like file not found case + if (error.response == undefined){ + reject(error.stack ); + } const exceptionClass = { 400: Exceptions.InvalidRequestError, 401: Exceptions.AuthenticationError, diff --git a/package.json b/package.json index a6ffb81..7c9db7e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "plivo", - "version": "4.18.0", + "version": "4.18.1", "description": "A Node.js SDK to make voice calls and send SMS using Plivo and to generate Plivo XML", "homepage": "https://github.com/plivo/plivo-node", "files": [