ropensci / piggyback
1

2
#' Get the download url of a given file
3
#'
4
#' Returns the URL download for a public file. This can be useful when writing
5
#' scripts that may want to download the file directly without introducing any
6
#' dependency on `piggyback` or authentication steps.
7
#' @inheritParams pb_download
8
#' @return the URL to download a file
9
#' @export
10
#' @examples \dontrun{
11
#'
12
#' pb_download_url("data/iris.tsv.xz",
13
#'                 repo = "cboettig/piggyback-tests",
14
#'                 tag = "v0.0.1")
15
#'
16
#' }
17
pb_download_url <- function(file = NULL,
18
                            repo = guess_repo(),
19
                            tag = "latest",
20
                            .token = get_token()) {
21 1
  df <- pb_info(repo, tag, .token)
22 1
  if (is.null(file)) {
23 1
    return(df$browser_download_url)
24 1
  } else if (file %in% df$file_name) {
25 0
    return(df[file == df$file_name, "browser_download_url"])
26
  } else {
27 1
    stop(paste("file", file, "not found in release", tag, "for repo", repo))
28
  }
29
}

Read our documentation on viewing source code .

Loading