Exemplo n.º 1
0
// SendGroupAttachment sends an attachment to a given group.
func SendGroupAttachment(hexid string, msg string, r io.Reader) (uint64, error) {
	ct, r := magic.MIMETypeFromReader(r)
	a, err := uploadAttachment(r, ct)
	if err != nil {
		return 0, err
	}
	return sendGroupHelper(hexid, msg, a)
}
Exemplo n.º 2
0
// contentType gets the content type (message, picture, video) of an attachment by sniffing its MIME type
func contentType(att io.Reader, mt string) int {
	if att == nil {
		return ContentTypeMessage
	}
	if mt == "" {
		mt, _ = magic.MIMETypeFromReader(att)
	}
	return mimeTypeToContentType(mt)
}
Exemplo n.º 3
0
// SendAttachment sends the contents of a reader, along
// with an optional message to a given contact.
func SendAttachment(tel, msg string, r io.Reader) (uint64, error) {
	ct, r := magic.MIMETypeFromReader(r)
	a, err := uploadAttachment(r, ct)
	if err != nil {
		return 0, err
	}
	omsg := &outgoingMessage{
		tel:        tel,
		msg:        msg,
		attachment: a,
	}
	return sendMessage(omsg)
}