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

AWSSDK.S3.list_objects_v2 continuation token does not paginate #16

Open
tclements opened this issue Jun 16, 2020 · 4 comments
Open

AWSSDK.S3.list_objects_v2 continuation token does not paginate #16

tclements opened this issue Jun 16, 2020 · 4 comments

Comments

@tclements
Copy link

AWSSDK.S3.list_objects_v2 cannot use continuation-token when making paginating requests. This seems similar to #10

Relevant package versions

(@v1.4) pkg> st
Status `~/.julia/environments/v1.4/Project.toml`
  [4f1ea46c] AWSCore v0.6.14
  [1c724243] AWSS3 v0.6.12
  [0d499d91] AWSSDK v0.5.0

MWE using AWSSDK.S3.list_objects_v2

using AWSCore, AWSSDK.S3
aws = aws_config(region="us-east-1")
bucket = "XXXX"
prefix = "XXX/XX=XXX/XXX=XXX/XX=XXXX"
s3req = AWSSDK.S3.list_objects_v2( aws,Bucket=bucket,prefix=prefix)
# returns 1000 keys 

# next request try with continuation 
s3req = AWSSDK.S3.list_objects_v2(
    aws,
    Bucket=bucket,
    prefix=prefix,
    continuation-token=string(s3req["NextContinuationToken"]),
)
ERROR: syntax: invalid keyword argument name "(continuation - token)"
Stacktrace:
 [1] top-level scope at REPL[469]:1

which is not a valid keyword in Julia. Trying the what was suggested in #10 with headers

# next request
d = ["prefix"=>prefix,"Bucket"=>bucket,"headers"=>["continuation-token"=>string(s3req["NextContinuationToken"])]]
s3req = AWSSDK.S3.list_objects_v2(aws,d)

just returns the first 1000 keys of the original request. I've tried every combination of ContinuationToken, Continuation_Token, continuation_token, etc.. to get pagination working.

Please let me know if I am missing something obvious in using the continuation-token option.

@mattBrzezinski
Copy link
Member

Haha, I believe I had just stumbled upon this while re-working on my unification of AWSCore.jl and this package into one unified package AWS.jl.

As you mentioned Julia does not support hyphens in variable names, however AWS uses this style for arguments. What we need to do is something like this here.

Basically pass in these arguments which AWS expects in a Julia-friendly format, then convert the query string before making the request. In my example above I've default to using underscores (continuation_token), since that seems both the easiest and most appropriate.

Tomorrow I can make a patch fix (unless you'd like to yourself), add some tests based off of your MWE and release the new version!

@tclements
Copy link
Author

Awesome, thanks for the quick response!

@mattBrzezinski
Copy link
Member

@tclements a work around to unblock yourself would be to do the below. I will still be working on a patch / discussing as I am not a fan of this styling.

s3req = AWSSDK.S3.list_objects_v2(
    aws,
    Bucket=bucket,
    prefix=prefix,
    var"continuation-token"=string(s3req["NextContinuationToken"]),
)

@tclements
Copy link
Author

@mattBrzezinski thanks! var trick works for the moment. Looking forward to AWS.jl!

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

Successfully merging a pull request may close this issue.

2 participants