Skip to contents

Download data from an existing release

Usage

pb_download(
  file = NULL,
  dest = ".",
  repo = guess_repo(),
  tag = "latest",
  overwrite = TRUE,
  ignore = "manifest.json",
  use_timestamps = TRUE,
  show_progress = getOption("piggyback.verbose", default = interactive()),
  .token = gh::gh_token()
)

Arguments

file

character: vector of names of files to be downloaded. If NULL, all assets attached to the release will be downloaded.

dest

character: path to destination directory (if length one) or vector of destination filepaths the same length as file. Any directories in the path provided must already exist.

repo

string: GH repository name in format "owner/repo". Default guess_repo() tries to guess based on current working directory's git repository

tag

string: tag for the GH release, defaults to "latest"

overwrite

boolean: should any local files of the same name be overwritten? default TRUE

ignore

character: vector of files to ignore (used if downloading "all" via file=NULL)

use_timestamps

DEPRECATED.

show_progress

logical, show a progress bar be shown for uploading? Defaults to interactive() - can also set globally with options("piggyback.verbose")

.token

GitHub authentication token, see gh::gh_token()

Examples

# \donttest{
try({
   ## Download a specific file.
   ## (if dest is omitted, will write to current directory)
   dest <- tempdir()
   piggyback::pb_download(
     "iris.tsv.gz",
     repo = "cboettig/piggyback-tests",
     tag = "v0.0.1",
     dest = dest
   )
   list.files(dest)
   ## Download all files
   piggyback::pb_download(
     repo = "cboettig/piggyback-tests",
     tag = "v0.0.1",
     dest = dest
   )
   list.files(dest)
})
#>  [1] "bslib-6f75d26c4219bb8bfd163af702cdeb26"
#>  [2] "diamonds.tsv.gz"                       
#>  [3] "downlit"                               
#>  [4] "file79739c9e924"                       
#>  [5] "file7973a88da9e"                       
#>  [6] "file7974a64ff20"                       
#>  [7] "file797569f6028"                       
#>  [8] "file7975bd2d5e7"                       
#>  [9] "file79779eb2521"                       
#> [10] "iris.tsv.gz"                           
#> [11] "iris.tsv.xz"                           
#> [12] "iris2.tsv.gz"                          
# \dontshow{
   try(unlink(list.files(dest, full.names = TRUE)))
 # }
# }