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

How to GET an object with a specific versionId from S3 #275

Open
duffau opened this issue Nov 28, 2018 · 0 comments
Open

How to GET an object with a specific versionId from S3 #275

duffau opened this issue Nov 28, 2018 · 0 comments

Comments

@duffau
Copy link

duffau commented Nov 28, 2018

I'm trying to retrieve an S3 object with a specific versionId. In AWS's REST API documentation the versionId should be placed as a named parameter ?versionId=<the version ID>. But appending this string to the path of s3HTTP returns a "NoSuchKey".

Looking into the function setup_s3_url called in line 93 in s3HTTP.R
it percent-encodes the URL, so characters like "=" and "&" are mapped to "%3F" and "%3D" respectively.

This happens in line 358 of setup_s3_url in s3HTTP.R, where utils::URLencode is called with the parameter reserved = TRUE which makes all reserved characters like "=" and "&" be percent-encoded.

I understand that one would want to sanitize the URL, but is this a bug or a feature?

If it's a feature, how should I pass the versionId argument to s3HTTP and the other more high level functions like s3read_using?

> library("aws.s3")
> version_id <- '3GL4kqtJlcpXroDTDm3vjVBH40Nr8X8g'
> object_path <- sprintf('%s?versionId=%s', 'my_object',  version_id)
> aws.s3::s3HTTP(verb = 'GET', bucket = 'my_bucket_name', path = object_path)
List of 5
 $ Code     : chr "NoSuchKey"
 $ Message  : chr "The specified key does not exist."
 $ Key      : chr "my_object?versionId=3GL4kqtJlcpXroDTDm3vjVBH40Nr8X8g"
 ...
Error in parse_aws_s3_response(r, Sig, verbose = verbose) : 
  Not Found (HTTP 404).
@duffau duffau changed the title How to GET an object with a specific versionId from S3 How to GET an object with a specific versionId from S3 Nov 29, 2018
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