figured out image upload to matrix but now jpeg is hard coded
parent
2b6acc51fb
commit
d3fff1519b
|
|
@ -1,6 +1,7 @@
|
|||
package message
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"local/truckstop/config"
|
||||
|
|
@ -129,14 +130,15 @@ func (m Matrix) SendImage(uri string) error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
publicURI, err := UploadImage(b)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
c, err := m.getclient()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
mediaUpload, err := c.UploadToContentRepo(bytes.NewReader(b), "image/jpeg", int64(len(b)))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
publicURI := mediaUpload.ContentURI
|
||||
resp, err := c.SendImage(m.room, "img", publicURI)
|
||||
log.Printf("sent image %s => %s: %+v", uri, publicURI, resp)
|
||||
return err
|
||||
|
|
|
|||
Loading…
Reference in New Issue