Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #407—list Backblaze S3 contents #408

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Authors@R: c(person("Thomas J.", "Leeper", role = "aut",
person("Andrii", "Degtiarov", role = "ctb"),
person("Dhruv", "Aggarwal", role = "ctb"),
person("Alyssa", "Columbus", role = "ctb"),
person("Michael", "Enion", role = "ctb"),
person("Simon", "Urbanek", role = c("cre", "ctb"),
email = "[email protected]")
)
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.22x

* `get_bucket_df` no longer throws an error when listing bucket contents from a Backblaze S3 bucket. Fixes #407.

# aws.s3 0.3.22

## API changes
Expand Down
32 changes: 19 additions & 13 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -92,22 +92,28 @@ get_objectkey.s3_object <- function(x, ...) {
#' @export
as.data.frame.s3_bucket <- function(x, row.names = NULL, optional = FALSE, ...) {
if (length(x)) {
out <- lapply(x, function(z) {
c(Key = z[["Key"]],
LastModified = z[["LastModified"]],
ETag = z[["ETag"]],
Size = z[["Size"]],
Owner_ID =
ifelse(is.null(z[["Owner"]]), NA, z[["Owner"]][["ID"]]),
Owner_DisplayName =
ifelse(is.null(z[["Owner"]]), NA, z[["Owner"]][["DisplayName"]]),
StorageClass = z[["StorageClass"]],
Bucket = z[["Bucket"]])
x <- lapply(x, function(z) {
lst = c(Key = z[["Key"]],
LastModified = z[["LastModified"]],
ETag = z[["ETag"]],
Size = z[["Size"]],
Owner_ID = z[["Owner"]][["ID"]],
Owner_DisplayName = z[["Owner"]][["DisplayName"]],
StorageClass = z[["StorageClass"]],
Bucket = z[["Bucket"]])

# any null values will be dropped, so add back in
# only seems to be a problem for the "Owner" properties, so assuming for
# now that the others are correct.
if(is.null(lst[["Owner_DisplayName"]])) lst[["Owner_DisplayName"]] = NA
if(is.null(lst[["Owner_ID"]])) lst[["Owner_ID"]] = NA
return(lst)

})
op <- options(stringsAsFactors = FALSE)
on.exit(options(op))
out <- do.call("rbind.data.frame", unname(out))
names(out) <- c("Key", "LastModified", "ETag", "Size", "Owner_ID", "Owner_DisplayName", "StorageClass", "Bucket")
out <- do.call("rbind.data.frame", unname(x))
names(out) <- names(x$Contents)
structure(out, row.names = if(!is.null(row.names)) row.names else seq_len(nrow(out)),
Marker = attributes(x)[["Marker"]],
IsTruncated = attributes(x)[["IsTruncated"]],
Expand Down