Hi friends! I need to save media messages to physical files I can play outside the projects. Example: Image, Audio, Video...
When I do: data, err := message.Download() I can't see a file with the final file...
PD: I know others languages but I'm novice in Go :(
Thanks!
if it's on linux, the downloaded file will be in / tmp
You need to move it, where you like (/tmp will be deleted if you restart your server)
as sample below, downloaded file will copy to directory "media/"
with filename same as original
data, err := message.Download()
filename := fmt.Sprintf("%v/%v.%v", "media", message.Info.Id, strings.Split(message.Type, "/")[1])
file, err := os.Create(filename)
defer file.Close()
_, err = file.Write(data)
Pretty thanks @hrizal it worked perfect! :)
Most helpful comment
if it's on linux, the downloaded file will be in / tmp
You need to move it, where you like (/tmp will be deleted if you restart your server)
as sample below, downloaded file will copy to directory "media/"
with filename same as original