-
There's only https://pkg.go.dev/github.com/mymmrac/telego#Bot.GetFile function related to downloading files. How can I use its |
Beta Was this translation helpful? Give feedback.
Answered by
mymmrac
Apr 7, 2023
Replies: 1 comment 3 replies
-
It's actually written in comment of this func, So you would download it from URL using something like this: DownloadFile("some.file", "https://api.telegram.org/file/bot<token>/<file_path>")
// ...
func DownloadFile(filepath string, url string) error {
// Get the data
resp, err := http.Get(url)
if err != nil {
return err
}
defer resp.Body.Close()
// Create the file
out, err := os.Create(filepath)
if err != nil {
return err
}
defer out.Close()
// Write the body to file
_, err = io.Copy(out, resp.Body)
return err
} |
Beta Was this translation helpful? Give feedback.
3 replies
Answer selected by
knightpp
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It's actually written in comment of this func,
The file can then be downloaded via the link https://api.telegram.org/file/bot<token>/<file_path>, where <file_path> is taken from the response.
.So you would download it from URL using something like this: