Please update Upload documentation
FabioSebs opened this issue · 3 comments
FabioSebs commented
If waProto is deprecated I can't seem to find the correct way to Upload a pdf or a png. Can you please provide a working example in the documentation thank you guys
FabioSebs commented
This is how I am currently trying it but I get no message unfortunately. Is there something I am missing?
func SendInvoiceExample(filename string) (err error) {
var (
msg string = "hello world!"
ctx = context.Background()
)
fileData, err := os.ReadFile(filename)
if err != nil {
return
}
resp, err := w.client.Upload(ctx, fileData, whatsmeow.MediaImage)
if err != nil {
return
}
toJID := types.JID{
User: "12345678901",
Server: types.DefaultUserServer,
}
message := &waE2E.ImageMessage{
Caption: proto.String("Hello, world!"),
URL: &resp.URL,
Mimetype: proto.String("image/png"),
FileLength: &resp.FileLength,
MediaKey: resp.MediaKey,
FileEncSHA256: resp.FileEncSHA256,
FileSHA256: resp.FileSHA256,
}
_, err = w.client.SendMessage(ctx, toJID, &waE2E.Message{
Conversation: &msg,
ImageMessage: message,
})
return
}
tulir commented
Only one top-level type in waE2E.Message
must be set. Conversation
and ImageMessage
are mutually exclusive.
FabioSebs commented
thanks a lot man , respect your hard work 👍🏼