0

I am trying to upload a picture to a channel using the code in this link:

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);
});

File is uploaded and image is shared successfully, but i would like to show upload progress to the user. How can i do it?

Also, while displaying images, is there a way to get thumbnail of the image first so as to not download the entire image unless user wants to see it?

No examples of the upload progress code is provided in Github sample project.

Koder
  • 1,794
  • 3
  • 22
  • 41

1 Answers1

0

Twilio developer evangelist here.

I'm afraid that it is currently not possible to get progress events with the JavaScript API. Also, there is no thumbnails of images available either, you can get the image URL using message.media.getContentUrl() and that only resolves the promise with a single URL and doesn't take options.

philnash
  • 70,667
  • 10
  • 60
  • 88
  • Can we expect those in the future ? – Koder Oct 03 '17 at 17:21
  • Documentation said `"Programmable Chat will provide you feedback of upload progress as well as an indication your media has been successfully saved."` [So your documentation is clearly wrong](https://www.twilio.com/docs/api/chat/guides/media-support). This is confusing. I am not sure which parts of the documentation are right. – Koder Oct 03 '17 at 17:31
  • Apologies for that, I am told that this is coming in a future release of the JS SDK, though it is available in both the Android and iOS SDKs. I'll get in touch with the documentation team to correct that. – philnash Oct 03 '17 at 21:51
  • Also, I've learned that we will be bringing thumbnails to the media uploads in the future too. – philnash Oct 04 '17 at 09:00