Skip to content

Commit

Permalink
Merge pull request nagdevAmruthnath#6 from vstathias/master
Browse files Browse the repository at this point in the history
added ability to override default environmental variables for minio connection
  • Loading branch information
nagdevAmruthnath authored Nov 11, 2021
2 parents 4ae6351 + 2986672 commit 3345f00
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 12 deletions.
31 changes: 27 additions & 4 deletions R/get_object.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down
36 changes: 28 additions & 8 deletions R/put_object.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit 3345f00

Please sign in to comment.