#' Download Files
#'
#' Download files from a remote location.
#'
#' @param url The duck URL for a remote file.
#' @param path Path to write to.
#' @param user The username or access key. Define with [duck_user()].
#' @param ... Additional arguments passed to duck.
#' @return The path to the downloaded files (invisibly).
#' @examples
#' duck_download("s3:/publicaccountability/csv/vt_voters.csv", tempfile())
#' @importFrom fs as_fs_path
#' @export
duck_download <- function(url, path, user = Sys.getenv("S3_USER"), ...) {
dots <- list(...)
arg_down <- paste("--download", url, path)
arg_user <- paste("--user", user)
system2(
command = "duck",
args = c("--quiet", arg_down, arg_user, dots),
stdout = TRUE,
stderr = "",
)
invisible(fs::as_fs_path(path))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.