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

s3_20060301 listObjectsV2 returns empty body #15

Open
refacktor opened this issue May 23, 2024 · 1 comment
Open

s3_20060301 listObjectsV2 returns empty body #15

refacktor opened this issue May 23, 2024 · 1 comment

Comments

@refacktor
Copy link

refacktor commented May 23, 2024

I am now using version 2626.5.2 with the latest fixes.

Trying to list the contents of an S3 bucket.

After looking at the example in the README and looking at the code in s3_20060301.nim, this was my best attempt:

import atoz/s3_20060301

when isMainModule:
  let rs = listObjectsV2.call(Bucket = "...actual-bucket-name...");
  echo rs.body

Output:

(blank line)

This probably is user error. I don't know enough Nim yet to be able to debug further. e.g. echo rs.headers doesn't compile.

Any tips on where to look next, would be appreciated!

@disruptek
Copy link
Owner

Most of my code that uses this stuff was written at my former employer, but I think call syntax is supposed to closely follow the HTTP method arguments as in the following:

let query = %* { "delimiter": "/", "max-keys": 1000 }
let path = %* { "Bucket": "some-bucket" }
# create the recallable
let recall = listObjectsV2.call(query = query, path = path)
# issue the call and close the fd
let reply = recall.issueAndClose()
if reply.code.is2xx:
  var stream = newStringStream reply.body
  let xml = parseXml stream
  let contents = xml.findAll "Contents"
  # ...
else:
  raise KeyError.newException reply.uncompressed

This probably looks really verbose to you, but realize that these APIs are all wrappers generated from the OpenAPI specifications; the verbosity of the generated API can be really critical to allowing the user to hack together any crazy combination of input validators, service url transmogrification, response processors, threaded clients, mocked calls, and so on. It's really designed to be the layer beneath the API that you write for "normal" use.

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