【问题标题】:Sendbird send image fileSendbird 发送图像文件
【发布时间】:2017-03-18 20:33:40
【问题描述】:

我正在查看JavaScript documentation for Sendbird,虽然发送文件的方法在那里,但没有解释每个参数必须是什么或不同的选项。

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

我发现这个stackoverflow question 对我有一些指导,但我仍然无法发送文件。

有人能够使用 JavaScript 使用 sendbird 发送图像吗?我正在寻找有关可用的多个选项的有效 JS 示例和/或文档。

【问题讨论】:

    标签: javascript sendbird


    【解决方案1】:

    要发送文件消息,您只需要函数中的一个参数,即定义您的来源的参数。基本功能不需要其他参数。

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

    对于源文件,您只需在本地或全局定义它的路径。希望对您有所帮助。

    这是一个有用的链接:https://github.com/smilefam/SendBird-JavaScript/blob/master/react-native-sample/SendBirdReactNativeSample/src/pages/chat.js

    【讨论】:

      【解决方案2】:

      在 React Native 中,你应该传递类似的东西

      { uri: 'file://p/q/a.jpg' name: 'a.jpg' type: 'image/jpg' }
      

      到 sendFileMessage 方法。

      这是您应该查看的示例代码。

      https://github.com/smilefam/SendBird-JavaScript/blob/master/react-native-sample/SendBirdReactNativeSample/src/pages/chat.js#L178

      【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-02-28
      • 2019-09-24
      • 2013-02-20
      • 2013-01-05
      • 1970-01-01
      • 2015-01-28
      相关资源
      最近更新 更多