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

Validate object hashes from gcs_list_objects() #128

Open
MarkEdmondson1234 opened this issue Aug 17, 2020 · 1 comment
Open

Validate object hashes from gcs_list_objects() #128

MarkEdmondson1234 opened this issue Aug 17, 2020 · 1 comment

Comments

@MarkEdmondson1234
Copy link
Collaborator

Thanks to @noamross this lets you validate the file hashes:

 map_chr(files_to_upload, ~base64enc::base64encode(wkb::hex2raw(digest::digest(file = ., algo = "md5"))))
@MarkEdmondson1234
Copy link
Collaborator Author

From https://github.com/ianmcook/wkb/blob/master/R/hex2raw.R

hex2raw <- function(hex) {
  if(!(is.character(hex) || (is.list(hex) &&
    all(vapply(X = hex, FUN = is.character, FUN.VALUE = logical(1)))))) {
    stop("hex must be a character string or character vector")
  }
  if(is.list(hex) || (length(hex) > 1 &&
     all(vapply(X = hex, FUN = nchar, FUN.VALUE = integer(1)) > 2))) {
    lapply(hex, .hex2raw)
  } else {
    .hex2raw(hex)
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant