From fc7a5b3b0e3cd9ff5e52a0daf046dfa3335ec719 Mon Sep 17 00:00:00 2001 From: Joe Hosteny Date: Tue, 19 Nov 2024 13:52:03 -0500 Subject: [PATCH] hotfix: manually patch generated code for custom S3 metadata This is only necessary until https://github.com/aws-beam/aws-elixir/pull/201 and https://github.com/aws-beam/aws-codegen/pull/117 are merged, and a new release of the aws-elixir library is done. --- lib/aws/generated/s3.ex | 32 ++++++++++++++++++++++++++++---- lib/aws/request.ex | 9 +++++++++ 2 files changed, 37 insertions(+), 4 deletions(-) diff --git a/lib/aws/generated/s3.ex b/lib/aws/generated/s3.ex index b3324eb2..a0c9f7b5 100644 --- a/lib/aws/generated/s3.ex +++ b/lib/aws/generated/s3.ex @@ -4787,6 +4787,12 @@ defmodule AWS.S3 do ] |> Request.build_params(input) + {custom_headers, input} = + [ + {"Metadata", "x-amz-meta-"} + ] + |> Request.build_params(input) + query_params = [] options = @@ -4809,7 +4815,7 @@ defmodule AWS.S3 do meta = metadata() - Request.request_rest(client, meta, :put, url_path, query_params, headers, input, options, 200) + Request.request_rest(client, meta, :put, url_path, query_params, custom_headers ++ headers, input, options, 200) end @doc """ @@ -5324,6 +5330,12 @@ defmodule AWS.S3 do ] |> Request.build_params(input) + {custom_headers, input} = + [ + {"Metadata", "x-amz-meta-"} + ] + |> Request.build_params(input) + query_params = [] options = @@ -5352,7 +5364,7 @@ defmodule AWS.S3 do :post, url_path, query_params, - headers, + custom_headers ++ headers, input, options, 200 @@ -13299,6 +13311,12 @@ defmodule AWS.S3 do ] |> Request.build_params(input) + {custom_headers, input} = + [ + {"Metadata", "x-amz-meta-"} + ] + |> Request.build_params(input) + query_params = [] options = @@ -13332,7 +13350,7 @@ defmodule AWS.S3 do meta = metadata() - Request.request_rest(client, meta, :put, url_path, query_params, headers, input, options, 200) + Request.request_rest(client, meta, :put, url_path, query_params, custom_headers ++ headers, input, options, 200) end @doc """ @@ -14966,6 +14984,12 @@ defmodule AWS.S3 do ] |> Request.build_params(input) + {custom_headers, input} = + [ + {"Metadata", "x-amz-meta-"} + ] + |> Request.build_params(input) + query_params = [] options = @@ -14983,7 +15007,7 @@ defmodule AWS.S3 do :post, url_path, query_params, - headers, + custom_headers ++ headers, input, options, 200 diff --git a/lib/aws/request.ex b/lib/aws/request.ex index fa898c6b..b143b4e5 100644 --- a/lib/aws/request.ex +++ b/lib/aws/request.ex @@ -324,6 +324,15 @@ defmodule AWS.Request do nil -> {headers, params} + param_value when is_map(param_value) -> + headers = + Enum.reduce(param_value, headers, fn {k, v}, headers -> + [{header_name <> k, v}] ++ headers + end) + + params = Map.delete(params, param_name) + {headers, params} + param_value -> headers = [{header_name, param_value} | headers] params = Map.delete(params, param_name)