R/awscli.R

Defines functions awscli

awscli <- function(src, dest, includes = NULL, excludes = NULL, args = "", profile = NULL, intern = FALSE) {
  constructArg <- function(x, s) {
    if (is.null(x)) {
      return(x)
    }
    paste(paste0(s, " \"", x, "\""), collapse = " ")
  }

  includes <- constructArg(includes, "--include")
  excludes <- constructArg(excludes, "--exclude")
  profile <- if (is.null(profile)) "" else paste("--profile", profile)
  dest <- paste("\"", dest, "\"", sep = "")
  src <- if (!is.null(src)) paste("\"", src, "\"", sep = "") else NULL

  command <- paste(
    "aws s3",
    args,
    excludes,
    includes,
    profile,
    src,
    dest
  )
  # cat(command, "\n")

  system(command, intern = intern, wait = TRUE, ignore.stdout = FALSE, ignore.stderr = FALSE)
}
INWTlab/rsync documentation built on April 3, 2022, 10:11 a.m.