api_get_file.go 375 B

123456789101112131415161718192021
  1. package telegram
  2. import (
  3. "context"
  4. "net/url"
  5. )
  6. // GetFile get download info of File by fileID from Telegram.
  7. func (b *Bot) GetFile(ctx context.Context, fileID string) (*File, error) {
  8. formData := url.Values{
  9. "file_id": {fileID},
  10. }
  11. var result File
  12. err := b.postForm(ctx, "/getFile", formData, &result)
  13. if err != nil {
  14. return nil, err
  15. }
  16. return &result, nil
  17. }