aws-beam / aws-codegen

Code generator for AWS clients in Erlang and Elixir.
Other
53 stars 49 forks source link

Add "receive_body_as_binary?" option to Elixir rest #74

Closed philss closed 3 years ago

philss commented 3 years ago

This is related to #71

This PR also includes new tests and a small refactor.

philss commented 3 years ago

~I'm going to merge this. Feel free to comment and I can fix later :)~ -> I found a problem. Looks like we are not detecting correctly some places that need to receive body as binary.

nicolae-shoreline commented 3 years ago

@philss how can I test this? I tried downloading latest aws-sdk-go and regenerated AWS.S3 but the payload is not interpreted as binary

philss commented 3 years ago

@nicolae-shoreline I just found a problem with that. I'm trying to figure out what is wrong. I will ping you when I have the fix to this :)

philss commented 3 years ago

@nicolae-shoreline the problem was in one branch of the template that handles "GET" requests. I fixed in the last commit: 60a171f

I pushed a new branch to aws-beam/aws-elixir that has the updated modules. Please give it a try: https://github.com/aws-beam/aws-elixir/tree/ps-receive-body-as-binary-generated-code

ceolinrenato commented 3 years ago

Tried with the newly generated modules and it worked:

Response from AWS.S3.get_object/22

{:ok,
 %{
   "Body" => <<0, 0, 0, 20, 102, 116, 121, 112, 113, 116, 32, 32, 0, 0, 0, 0,
     113, 116, 32, 32, 0, 0, 0, 8, 119, 105, 100, 101, 0, 86, 224, 26, 109, 100,
     97, 116, 0, 208, 64, 7, 0, 226, 155, 254, 210, 147, 96, ...>>,
   "ContentLength" => "5705489",
   "ContentType" => "undefined",
   "ETag" => "\"dd39793ca30fd65f7e028bad4e33ce1d\"",
   "LastModified" => "Thu, 25 Mar 2021 20:55:12 GMT",
   "VersionId" => "VaFWtwN3rg58TF9_RGWoLLHoNJW6iAjH"
 },
 %{
   body: <<0, 0, 0, 20, 102, 116, 121, 112, 113, 116, 32, 32, 0, 0, 0, 0, 113,
     116, 32, 32, 0, 0, 0, 8, 119, 105, 100, 101, 0, 86, 224, 26, 109, 100, 97,
     116, 0, 208, 64, 7, 0, 226, 155, 254, 210, 147, ...>>,
   headers: [
     {"x-amz-id-2",
      "wEbQ15Y1A365otHaWhsMrYpwIqvaIrfoc5eXk7FYAOtOgZJDIX9+mpfmF4om7or+e0VIvVf9a4k="},
     {"x-amz-request-id", "F5KD5Z0HXG5R28H8"},
     {"Date", "Fri, 26 Mar 2021 21:49:26 GMT"},
     {"Last-Modified", "Thu, 25 Mar 2021 20:55:12 GMT"},
     {"ETag", "\"dd39793ca30fd65f7e028bad4e33ce1d\""},
     {"x-amz-version-id", "VaFWtwN3rg58TF9_RGWoLLHoNJW6iAjH"}, 
     {"Accept-Ranges", "bytes"},
     {"Content-Type", "undefined"},
     {"Content-Length", "5705489"},
     {"Server", "AmazonS3"}
   ],
   status_code: 200
 }}
philss commented 3 years ago

@ceolinrenato thank you for testing this! :purple_heart:

berendeanicolae commented 3 years ago

@nicolae-shoreline the problem was in one branch of the template that handles "GET" requests. I fixed in the last commit: 60a171f

I pushed a new branch to aws-beam/aws-elixir that has the updated modules. Please give it a try: https://github.com/aws-beam/aws-elixir/tree/ps-receive-body-as-binary-generated-code

yes, works for me too. thank you!