2015-02-24 62 views
1

参考此问题:quickblox web how to upload profile pictureQuickblox消息附件

我想将上传的文件附加到新消息。创建

QB.content.createAndUpload({file: profile_picture, public: true}, function(error, response) { 
    if (error) { 
     console.log("upload didn't work"); 
    } else { 
     var blob_id = response.id; 
     // Example HERE // 
     var attachment = { 
      id: response.id.toString(), 
      name: response.name, 
      type: "photo", 
      url: response.path, 
      name: response.name, 
      'content-type': response.content_type 
      }; 
     QB.chat.message.create({ 
      attachments: [attachment] 
     },...) 
    } 
}); 

消息(见下面的照片),但是名称和内容类型的值不被保存到quickblox。下面的照片显示了使用Q-municate应用程序附加的文件,第二个内容来自上面引用的代码。你能否让我知道正确的做法是将附件添加到聊天消息中。由于

http://imgur.com/9QKNtXh

回答

0

正确的方法是登录响应和检查response.nameresponse.content_type - 它们可以被某种原因

为null,在这种情况下,您可以手动设置他们左右:

var attachment = { 
      id: response.id.toString(), 
      name: response.name, 
      type: "photo", 
      url: response.path, 
      name: "my image", 
      'content-type': "image/jpeg", 
      };