ex_aws icon indicating copy to clipboard operation
ex_aws copied to clipboard

Problem with Req HTTP Client

Open nicanor opened this issue 1 year ago • 0 comments

I tried to use the new Req HTTPClient, but it failed me when trying to download from S3 via stream

(ex_aws_s3 2.5.4) lib/ex_aws/s3/download.ex:98: ExAws.Operation.ExAws.S3.Download.stream!/2
(ex_aws_s3 2.5.4) lib/ex_aws/s3/download.ex:28: ExAws.S3.Download.build_chunk_stream/2
:erlang.binary_to_integer(["3047599"])
* 1st argument: not a binary

Problem is that the headers have a different format for Req.

I fixed the error by adding these lines to the response (I took them from your documentation in HTTP Client module):

headers =
  Enum.flat_map(headers, fn
    {name, vals} when is_list(vals) -> Enum.map(vals, &{name, &1})
    {name, val} -> {name, val}
  end)

This small change in ExAws.Request.Req fixed all my problems.

Please let me know if you need any more information

I'm happy to do the change myself if you want me to. In that case, please give me some instructions on how to contribute.

nicanor avatar Sep 10 '24 16:09 nicanor