diff --git a/lib/ex_aws/s3.ex b/lib/ex_aws/s3.ex index 08bd9cc..1ee7cfb 100644 --- a/lib/ex_aws/s3.ex +++ b/lib/ex_aws/s3.ex @@ -848,13 +848,21 @@ defmodule ExAws.S3 do | {:if_unmodified_since, binary} | {:if_match, binary} | {:if_none_match, binary} + | {:x_amz_checksum_mode, binary} @type head_object_opts :: [head_object_opt] @doc "Determine if an object exists" @spec head_object(bucket :: binary, object :: binary) :: ExAws.Operation.S3.t() @spec head_object(bucket :: binary, object :: binary, opts :: head_object_opts) :: ExAws.Operation.S3.t() - @request_headers [:range, :if_modified_since, :if_unmodified_since, :if_match, :if_none_match] + @request_headers [ + :range, + :if_modified_since, + :if_unmodified_since, + :if_match, + :if_none_match, + :x_amz_checksum_mode + ] def head_object(bucket, object, opts \\ []) do opts = opts |> Map.new() @@ -939,7 +947,14 @@ defmodule ExAws.S3 do @spec put_object(bucket :: binary, object :: binary, body :: binary, opts :: put_object_opts) :: ExAws.Operation.S3.t() def put_object(bucket, object, body, opts \\ []) do - request(:put, bucket, object, body: body, headers: put_object_headers(opts)) + {ct, content_hash} = calculate_content_hash(body) + + headers = + opts + |> put_object_headers() + |> Map.merge(%{ct => content_hash}) + + request(:put, bucket, object, body: body, headers: headers) end @doc "Create or update an object's access control policy"