download_file: Download once

Description Usage Arguments Value Examples

View source: R/download-file.R

Description

Download file if does not exist yet.

Usage

1
2
3
4
5
6
7
8
download_file(
  url,
  dir = tempdir(),
  fname = url_basename(url),
  overwrite = FALSE,
  mode = "wb",
  ...
)

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.

...

Arguments passed on to utils::download.file

method

Method to be used for downloading files. Current download methods are "internal", "wininet" (Windows only) "libcurl", "wget" and "curl", and there is a value "auto": see ‘Details’ and ‘Note’.

The method can also be set through the option "download.file.method": see options().

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, coming from the HTTPUserAgent option (see options) is used as the first header, automatically.

Value

Path to the downloaded (or existing) file.

Examples

1
2
3
download_file("https://github.com/privefl.png")
download_file("https://github.com/privefl.png")
download_file("https://github.com/privefl.png", overwrite = TRUE)

runonce documentation built on Oct. 2, 2021, 9:06 a.m.