From 37290194e196335a54a8bffde353c08ab3f450ee Mon Sep 17 00:00:00 2001 From: Julia Silge Date: Wed, 31 Aug 2022 15:53:40 -0600 Subject: [PATCH 1/4] Pass dots to `s3_upload_file()` --- R/board_s3.R | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/R/board_s3.R b/R/board_s3.R index ddd2e02d5..18f4e8224 100644 --- a/R/board_s3.R +++ b/R/board_s3.R @@ -39,10 +39,12 @@ #' an EC2 instance, using a role from another profile, and using multifactor #' authentication. #' -#' # Caveats +#' # Details #' #' * If you point at a bucket that's not created by pins, some functions #' like `pins_list()` will work, but won't return useful output. +#' * You can pass arguments for [paws.storage::s3_put_object] such as `Tagging` +#' and `ServerSideEncryption` through the dots of `pin_write()`. #' #' @inheritParams new_board #' @param bucket Bucket name. @@ -68,6 +70,10 @@ #' board_sales <- board_s3("company-pins", prefix = "sales/") #' board_marketing <- board_s3("company-pins", prefix = "marketing/") #' # You can make the hierarchy arbitrarily deep. +#' +#' # Pass arguments like `Tagging` through the dots of `pin_write`: +#' board %>% pin_write(mtcars, Tagging = "key1=value1&key2=value2") +#' #' } board_s3 <- function( bucket, @@ -209,14 +215,15 @@ pin_fetch.pins_board_s3 <- function(board, name, version = NULL, ...) { #' @export pin_store.pins_board_s3 <- function(board, name, paths, metadata, - versioned = NULL, ...) { + versioned = NULL, x = NULL, ...) { + ellipsis::check_dots_used() check_name(name) version <- version_setup(board, name, version_name(metadata), versioned = versioned) version_dir <- fs::path(name, version) s3_upload_yaml(board, fs::path(version_dir, "data.txt"), metadata) for (path in paths) { - s3_upload_file(board, fs::path(version_dir, fs::path_file(path)), path) + s3_upload_file(board, fs::path(version_dir, fs::path_file(path)), path, ...) } name @@ -267,12 +274,13 @@ s3_upload_yaml <- function(board, key, yaml) { ) } -s3_upload_file <- function(board, key, path) { +s3_upload_file <- function(board, key, path, ...) { body <- readBin(path, "raw", file.size(path)) board$svc$put_object( Bucket = board$bucket, Key = paste0(board$prefix, key), - Body = body + Body = body, + ... ) } From 22cfc3933225d28dae8be6d271ed979c85c30ff1 Mon Sep 17 00:00:00 2001 From: Julia Silge Date: Wed, 31 Aug 2022 15:53:56 -0600 Subject: [PATCH 2/4] Redocument --- man/board_s3.Rd | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/man/board_s3.Rd b/man/board_s3.Rd index a1bdbeb01..267b7f18b 100644 --- a/man/board_s3.Rd +++ b/man/board_s3.Rd @@ -79,10 +79,12 @@ an EC2 instance, using a role from another profile, and using multifactor authentication. } -\section{Caveats}{ +\section{Details}{ \itemize{ \item If you point at a bucket that's not created by pins, some functions like \code{pins_list()} will work, but won't return useful output. +\item You can pass arguments for \link[paws.storage:s3_put_object]{paws.storage::s3_put_object} such as \code{Tagging} +and \code{ServerSideEncryption} through the dots of \code{pin_write()}. } } @@ -96,5 +98,9 @@ board \%>\% pin_read("mtcars") board_sales <- board_s3("company-pins", prefix = "sales/") board_marketing <- board_s3("company-pins", prefix = "marketing/") # You can make the hierarchy arbitrarily deep. + +# Pass arguments like `Tagging` through the dots of `pin_write`: +board \%>\% pin_write(mtcars, Tagging = "key1=value1&key2=value2") + } } From 14ac979569f051dadb74abe02fce2e299256195a Mon Sep 17 00:00:00 2001 From: Julia Silge Date: Wed, 31 Aug 2022 16:04:54 -0600 Subject: [PATCH 3/4] Update NEWS --- NEWS.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/NEWS.md b/NEWS.md index 7635049c2..8c40d7181 100644 --- a/NEWS.md +++ b/NEWS.md @@ -4,6 +4,9 @@ * Fixed how Connect usernames are handled in messages, preview, etc (#643). +* Pass the dots from `pin_write()` through to `s3_upload_file()` to support + S3 tagging, encryption options, etc for pins (#648). + # pins 1.0.2 * `board_rsconnect()` now correctly finds the created date for pins (#623, From b20765a6fbadb34d00724cadd8392481e9e7913a Mon Sep 17 00:00:00 2001 From: Julia Silge Date: Wed, 31 Aug 2022 16:05:20 -0600 Subject: [PATCH 4/4] Check dots in final helper function --- R/board_s3.R | 1 + 1 file changed, 1 insertion(+) diff --git a/R/board_s3.R b/R/board_s3.R index 18f4e8224..09b7401ff 100644 --- a/R/board_s3.R +++ b/R/board_s3.R @@ -275,6 +275,7 @@ s3_upload_yaml <- function(board, key, yaml) { } s3_upload_file <- function(board, key, path, ...) { + ellipsis::check_dots_used() body <- readBin(path, "raw", file.size(path)) board$svc$put_object( Bucket = board$bucket,