diff --git a/DESCRIPTION b/DESCRIPTION index 9c11671..cae8d2d 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -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 = "simon.urbanek@R-project.org") ) diff --git a/NEWS.md b/NEWS.md index 40d2d8f..0070410 100644 --- a/NEWS.md +++ b/NEWS.md @@ -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 diff --git a/R/utils.R b/R/utils.R index be85368..fe0edf4 100644 --- a/R/utils.R +++ b/R/utils.R @@ -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"]],