getFile: Prepare a file for downloading

Description Usage Arguments Details Examples

View source: R/bot.R

Description

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.

Usage

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

Arguments

file_id

The file identifier.

destfile

(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.

Details

You can also use it's snake_case equivalent get_file.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
## 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)

telegram.bot documentation built on Oct. 30, 2019, 9:40 a.m.