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

Possibility of having gcs_get_object simply taking a full gs:// URI? #57

Closed
seandavi opened this issue Dec 14, 2016 · 2 comments
Closed

Comments

@seandavi
Copy link

I often find myself with objects using the fully-qualified URI including gs://BUCKETNAME/..... While I know that this would change the current API, what do you think about having gcs_get_object either "do the right thing" with those types of URIs or even making that the default behavior. Just wanted to hear your thoughts.

MarkEdmondson1234 added a commit that referenced this issue Dec 15, 2016
@MarkEdmondson1234
Copy link
Collaborator

That was easy enough to add in, I used this helper function:

# Parse gs:// URIs to bucket and name
gcs_parse_gsurls <- function(gsurl){
  testthat::expect_type(gsurl, "character")

  if(grepl("^gs://", gsurl)){
    ## parse out bucket and object name
    bucket <- gsub("^gs://(.+?)/(.+)$","\\1", gsurl)
    obj <- gsub(paste0("^gs://",bucket,"/"), "", gsurl)

    out <- list(bucket = bucket, obj = obj)
  } else {
    # not a gs:// URL
    out <- NULL
  }

  out

}

Test it out, and if looks ok it can be in the next CRAN release.

@seandavi
Copy link
Author

Quick testing--looks great. Thanks again for your generosity.

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

2 participants