Skip to content

Commit

Permalink
update pb_download_url examples
Browse files Browse the repository at this point in the history
  • Loading branch information
tanho63 committed Dec 29, 2023
1 parent 4307013 commit f235961
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 6 deletions.
29 changes: 26 additions & 3 deletions R/pb_download_url.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,34 @@
#' @examples \donttest{
#' \dontshow{try(\{}
#'
#' # returns browser url by default
#' pb_download_url("iris.tsv.xz", repo = "cboettig/piggyback-tests", tag = "v0.0.1")
#' # returns browser url by default (and all files if none are specified)
#' browser_url <- pb_download_url(
#' repo = "tanho63/piggyback-tests",
#' tag = "v0.0.2"
#' )
#' print(browser_url)
#' utils::read.csv(browser_url[[1]])
#'
#' # can return api url if desired
#' pb_download_url("iris.tsv.xz", repo = "cboettig/piggyback-tests", tag = "v0.0.1", url_type = "api")
#' api_url <- pb_download_url(
#' "mtcars.csv",
#' repo = "tanho63/piggyback-tests",
#' tag = "v0.0.2"
#' )
#' print(api_url)
#'
#' # for public repositories, this will still work
#' utils::read.csv(api_url)
#'
#' # for private repos, can use httr or curl to fetch and then pass into read function
#' gh_pat <- Sys.getenv("GITHUB_PAT")
#'
#' if(!identical(gh_pat, "")){
#' resp <- httr::GET(api_url, httr::add_headers(Authorization = paste("Bearer", gh_pat)))
#' utils::read.csv(text = httr::content(resp, as = "text"))
#' }
#'
#' # or use pb_read which bundles some of this for you
#'
#' \dontshow{\})}
#' }
Expand Down
6 changes: 3 additions & 3 deletions man/pb_download.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f235961

Please sign in to comment.