getFile: Prepare a file for downloading

View source: R/bot.R

getFileR Documentation

Prepare a file for downloading


Use this method to get basic info about a file and prepare it for downloading. For the moment, bots can download files of up to 20MB in size. It is guaranteed that the link will be valid for at least 1 hour. When the link expires, a new one can be requested by calling getFile again.


getFile(file_id, destfile = NULL, ...)



The file identifier.


(Optional). If you want to save the file, pass by a character string with the name where the downloaded file is saved. See the destfile parameter from ?curl::curl_download for further details.


(Optional). Additional parameters to be passed to curl_download. It is not used if destfile is NULL.


You can also use it's snake_case equivalent get_file.


## Not run: 
bot <- Bot(token = bot_token("RTelegramBot"))
chat_id <- user_id("Me")

photos <- bot$getUserProfilePhotos(chat_id = chat_id)

# Download user profile photo
file_id <- photos$photos[[1L]][[1L]]$file_id
bot$getFile(file_id, destfile = "photo.jpg")

## End(Not run) documentation built on Sept. 7, 2022, 5:07 p.m.