Search code examples
androidattachmentquickblox

Sending Image Attachment in Quickblox


Iam new to quickblox. Iam trying to send image in chat using quickblox.I have a doubt that can we use getPublicUrl method to pass the URL to the receiver and then using imageloader to load it.If yes then what is use of QBAttachment??


Solution

  • Yes you can,

    just pass QBFile.id to QBAttachment:

    // attach a photo
    QBFile someFile = ...;
    String fileId = "" + someFile.getId();
    QBAttachment attachment = new QBAttachment("photo");
    attachment.setId(fileId);
    chatMessage.addAttachment(attachment);
    

    And on the receiver side:

    QBAttachment attachment = ...;
    String fileId = attachment.getId();
    
    QBFile file = new QBFile();
    file.setId(Integer.valueOf(fileId));
    
    String publicUrl = file.getPublicUrl();