Download file if does not exist yet.
Arguments
- url
URL of file to be downloaded.
- dir
Directory where to download the file.
- fname
Base name of the downloaded file (
dir
will be prefixed).- overwrite
Whether to overwrite? Default is
FALSE
.- mode
See parameter of
download.file()
. Default of "wb" seems useful for Windows systems.- timeout
Number of seconds before timeout. Default is 300 (5 minutes).
- ...
Arguments passed on to
utils::download.file
method
Method to be used for downloading files. Current download methods are
"internal"
,"libcurl"
,"wget"
,"curl"
and"wininet"
(Windows only), and there is a value"auto"
: see ‘Details’ and ‘Note’.The method can also be set through the option
"download.file.method"
: seeoptions()
.quiet
If
TRUE
, suppress status messages (if any), and the progress bar.cacheOK
logical. Is a server-side cached value acceptable?
extra
character vector of additional command-line arguments for the
"wget"
and"curl"
methods.headers
named character vector of HTTP headers to use in HTTP requests. It is ignored for non-HTTP URLs. The
User-Agent
header taken from theHTTPUserAgent
option (seeoptions
) is automatically used as the first header.
Examples
download_file("https://github.com/privefl.png")
#> [1] "C:\\Users\\au639593\\AppData\\Local\\Temp\\Rtmp4Qgq1R/privefl.png"
download_file("https://github.com/privefl.png")
#> [1] "C:\\Users\\au639593\\AppData\\Local\\Temp\\Rtmp4Qgq1R/privefl.png"
download_file("https://github.com/privefl.png", overwrite = TRUE)
#> [1] "C:\\Users\\au639593\\AppData\\Local\\Temp\\Rtmp4Qgq1R/privefl.png"