Skip to content

Commit

Permalink
add location_constraint arg to put_bucket() (#189)
Browse files Browse the repository at this point in the history
  • Loading branch information
leeper committed Jul 30, 2018
1 parent 1251324 commit 874f6a7
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 10 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: aws.s3
Type: Package
Title: 'AWS S3' Client Package
Version: 0.3.18
Version: 0.3.19
Date: 2018-07-29
Authors@R: c(person("Thomas J.", "Leeper", role = c("aut", "cre"),
email = "thosjleeper@gmail.com",
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# aws.s3 0.3.19

* `put_bucket()` gains a `location_constraint` argument, which - if NULL - does not pass a LocationConstraint body argument. This is useful for S3-compatible storage. (#189)

# aws.s3 0.3.18

* Allowed both virtual- and path-style URLs for S3-compatible storage and fixed region handling for S3-compatible URLs. (#189)
Expand Down
18 changes: 10 additions & 8 deletions R/put_bucket.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#' @template bucket
#' @param region A character string containing the AWS region. If missing, defaults to value of environment variable \env{AWS_DEFAULT_REGION}.
#' @template acl
#' @param location_constraint A character string specifying a location constraint. If \code{NULL} (for example, for S3-compatible storage), no LocationConstraint body is passed.
#' @param headers List of request headers for the REST call.
#' @template dots
#' @return \code{TRUE} if successful.
Expand All @@ -26,19 +27,20 @@ function(bucket,
acl = c("private", "public-read", "public-read-write",
"aws-exec-read", "authenticated-read",
"bucket-owner-read", "bucket-owner-full-control"),
headers = list(),
location_constraint = region,
headers = list(),
...){
if (region == "us-east-1") {
b <- ""

if (!is.null(location_constraint) && location_constraint != "us-east-1") {
bod <- paste0('<CreateBucketConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/"><LocationConstraint>',
location_constraint, '</LocationConstraint></CreateBucketConfiguration>')
} else {
b <- paste0('<CreateBucketConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/"><LocationConstraint>',
region, '</LocationConstraint></CreateBucketConfiguration>')
bod <- ""
}
acl <- match.arg(acl)
headers <- c(list(`x-amz-acl` = acl), headers)
headers <- c(list(`x-amz-acl` = match.arg(acl)), headers)
ir <- s3HTTP(verb = "PUT",
bucket = bucket,
request_body = b,
request_body = bod,
headers = headers,
region = region,
check_region = FALSE,
Expand Down
4 changes: 3 additions & 1 deletion man/put_bucket.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 874f6a7

Please sign in to comment.