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

Upload object with metadata in folder fails due to urlencode #149

Open
mzusev opened this issue Jun 9, 2021 · 3 comments
Open

Upload object with metadata in folder fails due to urlencode #149

mzusev opened this issue Jun 9, 2021 · 3 comments

Comments

@mzusev
Copy link

mzusev commented Jun 9, 2021

Example:

meta <- gcs_metadata_object("test_folder/mtcars.csv",
                            metadata = list(id = '4D67djkdJL8'))

gcs_upload(mtcars,
           name = "test_folder/mtcar.csv",
           object_metadata = meta,
           predefinedAcl = "bucketLevel")

Fails with error:

Error: API returned: Value 'test_folder%2Fmtcars.csv' in content does not agree with value 'test_folder/mtcars.csv'. This can happen when a value set through a parameter is inconsistent with a value set in the request.

Forward slash seems to be due to the URLencode:

object_name <- if(!is.null(object_name)) URLencode(object_name)

Workaround is to update object name directly before calling gcs_upload:

meta$name <- "test_folder/mtcars.csv"

But this may interfere with other reserved characters for url encoding.

@MarkEdmondson1234
Copy link
Collaborator

Thanks for the report. I wonder if URL encoding is not necessary anymore in the gcs_upload()

@ghost
Copy link

ghost commented Aug 20, 2021

Hi! I encountered a similar problem today while trying to add caching details via gcs_metadata_object().

gcs_upload() and gcs_metadata_object() use different encodings for slashes. While gcs_upload uses "/", gcs_metadata_object() uses "%2F".

This is my work around, but a more stable fix would be great:

metaData <- gcs_metadata_object(object_name = paste0("folder/images/", filename_pure), cacheControl = "max-age=0, no-cache, no-store")

metaData[["name"]] <- gsub("%2F","/",metaData[["name"]])

@MarkEdmondson1234
Copy link
Collaborator

Thanks! Looks like an inconsistency between the functions, will look to standardise

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