diff --git a/R/get_object.R b/R/get_object.R index 6b70148..fa2d982 100644 --- a/R/get_object.R +++ b/R/get_object.R @@ -83,10 +83,33 @@ function(object, file = basename(object), overwrite = TRUE, use_https, + base_url, + region, + key, + secret, ...) { if (missing(bucket)) { bucket <- get_bucketname(object) } + + if (missing(base_url)) { + base_url = Sys.getenv("AWS_S3_ENDPOINT") + } + + + if (missing(region)) { + region = Sys.getenv("AWS_DEFAULT_REGION") + } + + if (missing(key)) { + key = Sys.getenv("AWS_ACCESS_KEY_ID") + } + + if (missing(secret)) { + secret = Sys.getenv("AWS_SECRET_ACCESS_KEY") + } + + object <- get_objectkey(object) # create dir() if missing @@ -107,11 +130,11 @@ function(object, parse_response = TRUE, check_region = FALSE, url_style = c("path", "virtual"), - base_url = Sys.getenv("AWS_S3_ENDPOINT"), + base_url = base_url, verbose = getOption("verbose", FALSE), - region = Sys.getenv("AWS_DEFAULT_REGION"), - key = Sys.getenv("AWS_ACCESS_KEY_ID"), - secret = Sys.getenv("AWS_SECRET_ACCESS_KEY"), + region = region, + key = key, + secret = secret, session_token = NULL, use_https = use_https) return(file) diff --git a/R/put_object.R b/R/put_object.R index 94836e5..96422c3 100644 --- a/R/put_object.R +++ b/R/put_object.R @@ -68,6 +68,26 @@ function(file, } object <- get_objectkey(object) } + + if (missing(base_url)) { + base_url = Sys.getenv("AWS_S3_ENDPOINT") + } + + + if (missing(region)) { + region = Sys.getenv("AWS_DEFAULT_REGION") + } + + if (missing(key)) { + key = Sys.getenv("AWS_ACCESS_KEY_ID") + } + + if (missing(secret)) { + secret = Sys.getenv("AWS_SECRET_ACCESS_KEY") + } + + + acl <- match.arg(acl) headers <- c(list(`x-amz-acl` = acl), headers) if (isTRUE(multipart)) { @@ -136,11 +156,11 @@ function(file, parse_response = TRUE, check_region = FALSE, url_style = c("path", "virtual"), - base_url = Sys.getenv("AWS_S3_ENDPOINT"), + base_url = base_url, verbose = getOption("verbose", FALSE), - region = Sys.getenv("AWS_DEFAULT_REGION"), - key = Sys.getenv("AWS_ACCESS_KEY_ID"), - secret = Sys.getenv("AWS_SECRET_ACCESS_KEY"), + region = region, + key = key, + secret = secret, session_token = NULL, use_https = FALSE) return(TRUE) @@ -179,11 +199,11 @@ post_object <- function(file, object, bucket, headers = list(), ...) { parse_response = TRUE, check_region = FALSE, url_style = c("path", "virtual"), - base_url = Sys.getenv("AWS_S3_ENDPOINT"), + base_url = base_url, verbose = getOption("verbose", FALSE), - region = Sys.getenv("AWS_DEFAULT_REGION"), - key = Sys.getenv("AWS_ACCESS_KEY_ID"), - secret = Sys.getenv("AWS_SECRET_ACCESS_KEY"), + region = region, + key = key, + secret = secret, session_token = NULL, use_https = FALSE) structure(r, class = "s3_object")