File: download.Rd

package info (click to toggle)
r-cran-remotes 2.5.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,000 kB
  • sloc: sh: 14; makefile: 2
file content (56 lines) | stat: -rw-r--r-- 1,803 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/download.R
\name{download}
\alias{download}
\title{Download a file}
\usage{
download(
  path,
  url,
  auth_token = NULL,
  basic_auth = NULL,
  quiet = TRUE,
  headers = NULL
)
}
\arguments{
\item{path}{Path to download to. \code{dirname(path)} must exist.}

\item{url}{URL.}

\item{auth_token}{Token for token-based authentication or \code{NULL}.}

\item{basic_auth}{List with \code{user} and \code{password} for basic HTTP
authentication, or \code{NULL}.}

\item{quiet}{Passed to \code{\link[=download.file]{download.file()}} or \code{\link[curl:curl_download]{curl::curl_download()}}.}

\item{headers}{Named character vector of HTTP headers to use.}
}
\value{
\code{path}, if the download was successful.
}
\description{
Uses either the curl package for R versions older than 3.2.0,
otherwise a wrapper around \code{\link[=download.file]{download.file()}}.
}
\details{
We respect the \code{download.file.method} setting of the user. If it is
not set, then see \code{download_method()} for choosing a method.

Authentication can be supplied three ways:
\itemize{
\item By setting \code{auth_token}. This will append an HTTP \code{Authorization}
header: \verb{Authorization: token \{auth_token\}}.
\item By setting \code{basic_auth} to a list with elements \code{user} and \code{password}.
This will append a proper \verb{Authorization: Basic \{encoded_password\}}
HTTP header.
\item By specifying the proper \code{headers} directly.
}

If both \code{auth_token} and \code{basic_auth} are specified, that's an error.
\code{auth_token} and \code{basic_auth} are \emph{appended} to \code{headers}, so they
take precedence over an \code{Authorization} header that is specified
directly in \code{headers}.
}
\keyword{internal}