Attachments / objects

Sharing an image, a document or just a gif is an important part of your users daily messaging, the SDK allows your app to send this kind of messages as well. Let’s see how.

Public objects

Most of the time we only share public images, and in this case we don’t require the document to be encrypted, so we can directly share the URL.

opts = { objects: [{ 
    link: "", 
    name: "homer",
    mime: "image/gif",
}] }
client.message user, "ready!", opts
obj := chat.MessageObject{
	Name: "Hello",
	Link: "",
	Mime: "image/gif",
m, err = client.ChatService().Message([]string{os.Args[1]}, "no way...", chat.MessageOptions{
	Objects: []chat.MessageObject{obj},
opts = { "objects": [{
    "link": "", 
    "name": "homer",
    "mime": "image/gif",
}]} user, "ready!", opts)

Non-public objects

All non-public objects shared between identities are encrypted by default using Poly1305. This encryption layer is built on the SDK, so should be transparent for end users. Let’s see how we can send a local file. do |image|
    name = "image.#{path.split(".").last}"
    mime = "image/#{path.split(".").last}"
    msg.message("your image sir...", objects: [{ name: name,
                                                 mime: mime }])
data, err := os.ReadFile("/tmp/dat")
m, err = cs.Message([]string{os.Args[1]}, "your file sir...", chat.MessageOptions{
	Objects: []chat.MessageObject{chat.MessageObject{
	Name: "image.gif",
	Data: data,
	Mime: "image/gif",
import * as fs from 'fs';
let data = fs.readFileSync('foo.txt','utf8'); user, "your file sir...", { "objects": [{
    "data": data, 
    "name": "image.gif",
    "mime": "image/gif",