Skip to content

Commit

Permalink
Add utility aws_s3_list_etags()
Browse files Browse the repository at this point in the history
  • Loading branch information
wlandau-lilly committed Nov 9, 2023
1 parent de94707 commit 51e34a2
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions R/utils_aws.R
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,52 @@ aws_s3_exists <- function(
)
}

aws_s3_list_etags <- function(
prefix,
bucket,
page_size = 1000L,
verbose = TRUE,
region = NULL,
endpoint = NULL,
version = NULL,
args = list(),
max_tries = NULL,
seconds_timeout = NULL,
close_connection = NULL,
s3_force_path_style = NULL
) {
client <- aws_s3_client(
endpoint = endpoint,
region = region,
seconds_timeout = seconds_timeout,
close_connection = close_connection,
s3_force_path_style = s3_force_path_style,
max_tries = max_tries
)
args$Bucket <- bucket
args$Prefix <- prefix
args <- supported_args(fun = client$list_objects_v2, args = args)
if (verbose) {
tar_message_run(
"Listing objects in AWS S3 bucket ",
bucket,
" prefix ",
prefix,
"..."
)
}
pages <- paws.common::paginate(
Operation = do.call(what = client$list_objects_v2, args = args)
)
out <- list()
for (page in pages) {
for (object in page$Contents) {
out[[object$Key]] <- eval(parse(text = object$ETag))
}
}
out
}

aws_s3_download <- function(
file,
key,
Expand Down

0 comments on commit 51e34a2

Please sign in to comment.