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 gcs_copy_object() to use bucketLevel permissions #132

Open
MarkEdmondson1234 opened this issue Oct 26, 2020 · 6 comments
Open

Fix gcs_copy_object() to use bucketLevel permissions #132

MarkEdmondson1234 opened this issue Oct 26, 2020 · 6 comments

Comments

@MarkEdmondson1234
Copy link
Collaborator

@MarkEdmondson1234 Thanks for the Hotfix. But i Think you missed the gcs_copy_object() function. There should also be a parametervalue "bucketLevel". I tried it with the latest github commit, but it didn't work. and it says

Request Status Code: 400
Error: API returned: Invalid string value: 'bucketLevel'. Allowed values: [authenticatedread, bucketownerfullcontrol, bucketownerread, private, projectprivate, publicread]

As long as the update isn't available in CRAN. Can you please post a snippet which removes the ACLs from the call to get this work?

Originally posted by @Pit-Storm in #111 (comment)

@MarkEdmondson1234
Copy link
Collaborator Author

@Pit-Storm best tracked in a new issue

It will involve adding a blank ACL object as shown in this commit 37f922c to the gcs_copy_object() code:

gcs_copy_object <- function(source_object,
destination_object,
source_bucket = gcs_get_global_bucket(),
destination_bucket = gcs_get_global_bucket(),
rewriteToken = NULL,
destinationPredefinedAcl = NULL){
assert_that(
is.string(source_object),
is.string(destination_object)
)
source_gcs <- gcs_parse_gsurls(source_object)
if(!is.null(source_gcs)){
source_object <- source_gcs$obj
source_bucket <- source_gcs$bucket
}
destination_gcs <- gcs_parse_gsurls(destination_object)
if(!is.null(destination_gcs)){
destination_object <- destination_gcs$obj
destination_bucket <- destination_gcs$bucket
}
source_bucket <- as.bucket_name(source_bucket)
destination_bucket <- as.bucket_name(destination_bucket)
source_object <- URLencode(source_object, reserved = TRUE)
destination_object <- URLencode(destination_object, reserved = TRUE)
the_url <- sprintf("https://www.googleapis.com/storage/v1/b/%s/o/%s/rewriteTo/b/%s/o/%s",
source_bucket, source_object, destination_bucket, destination_object)
pars <- NULL
if(!is.null(rewriteToken)){
pars <- list(rewriteToken = rewriteToken)
}
if(!is.null(destinationPredefinedAcl)){
assert_that(is.string(destinationPredefinedAcl))
pars <- c(pars, list(destinationPredefinedAcl = destinationPredefinedAcl))
}
ob <- gar_api_generator(the_url,
"POST",
pars_args = pars,
data_parse_function = function(x) x)
ob()
}

@MarkEdmondson1234
Copy link
Collaborator Author

@Pit-Storm what example code are you using to trigger your error? From the looks of it not specifying the ACL should respect that existing objects ACL level.

@Pit-Storm
Copy link

Pit-Storm commented Oct 26, 2020 via email

@MarkEdmondson1234
Copy link
Collaborator Author

I'm a bit confused as the default is NULL. May I ask for the example code you used and the sessionInfo(), it could be that its just fixed on GitHub?

@Pit-Storm
Copy link

Pit-Storm commented Oct 26, 2020 via email

@MarkEdmondson1234
Copy link
Collaborator Author

Makes sense, yes it can be changed to be more consistent.

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