Closed arsh-amar closed 3 years ago
Thanks for opening up your first issue!
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Following is the code to send media through Twillo
// example for sending media message as FormData // --------------------------------------------- const formData = new FormData(); formData.append('file', $('#formInputFile')[0].files[0]); // get desired channel (for example, with getChannelBySid promise) chatClient.getChannelBySid(channelSid).then(function(channel) { // send media with all FormData parsed atrtibutes channel.sendMessage(formData); });
// example for sending media message as String // ------------------------------------------- // get desired channel (for example, with getChannelBySid promise) chatClient.getChannelBySid(channelSid).then(function(channel) { // send SVG image as string with content type image/svg+xml; charset=utf-8 channel.sendMessage({ contentType: 'image/svg+xml; charset=utf-8', media: '', }); });
// example for sending media message as Buffer // ------------------------------------------- // get desired channel (for example, with getChannelBySid promise) chatClient.getChannelBySid(channelSid).then(function(channel) { // send PNG image as Buffer with content type image/png channel.sendMessage({ contentType: 'image/png', media: fs.readFileSync(pngFile), }); });