Search code examples
javascriptsendbird

Sendbird send image file


I'm going through the JavaScript documentation for Sendbird and although the method to send files is there, there is no explanation on what each argument has to be or the different options.

channel.sendFileMessage(FILE, FILE_NAME, FILE_TYPE, FILE_SIZE, CUSTOM_DATA, function(message, error){
    if (error) {
        console.error(error);
        return;
    }
    console.log(message);
});

I found this stackoverflow question that guided me a bit, but I'm still unable to send a file.

Has someone been able to send an image with sendbird using JavaScript? I'm looking for a working JS example and/or documentation about the multiple options available.


Solution

  • To send file message, you only need one of the argument in the function, the one which defines your source. The other arguments is not neccasary for the basic function.

    channel.sendFileMessage(File, function(message, error) {
      if (error) {
        console.log(error);
        return;
      }
    

    And for the source File, you need to just define the path to it either locally or globally. Hope it was helpful.

    Here is a useful link: https://github.com/smilefam/SendBird-JavaScript/blob/master/react-native-sample/SendBirdReactNativeSample/src/pages/chat.js