disruptek / atoz

Amazon Web Services (AWS) APIs in Nim
MIT License
48 stars 5 forks source link

S3 putObject requires JsonNode (JObject) for body instead of file #10

Closed nothratal closed 1 month ago

nothratal commented 1 year ago

the documentation for the putObject method against the S3 endpoint shows that files, which should be uploaded to S3, need to be placed plain as body in the PUT-request and not a json: http://docs.amazonwebservices.com/AmazonS3/latest/API/RESTObjectPUT.html

But the implementation asks for JsonNode (of JObject to be concrete) instead of file, which results in empty files in AWS S3. I know what I need to change to get it working, but the code is automatically generated, right? So adding it via a pull request wouldn't be helpful.

Assuming my code looks like the following:

var fileContent =readAll(filename.open)
var fileAsJObject = newJObject()
fileAsJObject.add(key="file",val=newJString(fileContent))

var resp = putObject.call(Bucket="order", Key="customerXYZ/pizza.txt", body=fileAsJObject).retried

then my workaround in s3_20060301 is the following:

The cleaner way would be of course to pass a file directly, but I don't see on which base the nim code will be generated.

disruptek commented 1 year ago

The code generator is available in https://github.com/disruptek/atoz/tree/master/generator if you want to mess with it. We've changed how this works several times now, to get around inconsistencies and errors in the OpenAPI sources, so it's probably time to update the CI with some credentials and add some tests.

disruptek commented 1 month ago

IIUC, this is resolved by passing the content argument with fileContent.