-
Notifications
You must be signed in to change notification settings - Fork 133
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
put_bucket_cors
request is incorrect
#171
Comments
So I did a hack to get this to work @tag_mappings %{
"AllowedHeaders" => "AllowedHeader",
"AllowedMethods" => "AllowedMethod",
"AllowedOrigins" => "AllowedOrigin",
"ExposeHeaders" => "ExposeHeader"
}
patched_cors_params =
Enum.map(cors_parameters, fn rule ->
Enum.map(rule, fn {k, v} ->
if k in Map.keys(@tag_mappings) do
key = Map.fetch!(@tag_mappings, k)
{key, v}
else
{k, v}
end
end)
|> Enum.into(%{})
end) Not sure how I would do it in this library though, if you give me some guidance I can submit a PR |
Sorry for the delay @zacksiri but by the looks of it, I believe your Shouldn't be as simple as: cors_parameters = [
%{
"AllowedHeader" => ["Content-Type", "Content-MD5", "Content-Disposition"],
"AllowedMethod" => ["PUT"],
"AllowedOrigin" => ["https://some-example.com"],
"MaxAgeSeconds" => 3600
}
]
AWS.S3.put_bucket_cors(client, bucket_name, %{
"CORSConfiguration" => %{
"CORSRule" => cors_parameter
}
}) Which seems to create a legit <CORSConfiguration>
<CORSRule>
<AllowedHeader>Content-Type</AllowedHeader>
<AllowedHeader>Content-MD5</AllowedHeader>
<AllowedHeader>Content-Disposition</AllowedHeader>
<AllowedMethod>PUT</AllowedMethod>
<AllowedOrigin>https://some-example.com</AllowedOrigin>
<MaxAgeSeconds>3600</MaxAgeSeconds>
</CORSRule>
</CORSConfiguration> This also seems to work fine with multiple CORSRules as per example: cors_parameter2 = [
%{
"AllowedHeader" => ["Content-Type", "Content-MD5", "Content-Disposition"],
"AllowedMethod" => ["PUT"],
"AllowedOrigin" => ["https://some-example.com"],
"MaxAgeSeconds" => 3600
},
%{
"AllowedHeader" => ["Content-MD5"],
"AllowedMethod" => ["GET"],
"AllowedOrigin" => ["https://some-example.com"],
"MaxAgeSeconds" => 1800
}
]
AWS.S3.put_bucket_cors(client, "foo", %{
"CORSConfiguration" => %{
"CORSRule" => cors_parameter2
}
}) which generates: <CORSConfiguration>
<CORSRule>
<AllowedHeader>Content-Type</AllowedHeader>
<AllowedHeader>Content-MD5</AllowedHeader>
<AllowedHeader>Content-Disposition</AllowedHeader>
<AllowedMethod>PUT</AllowedMethod>
<AllowedOrigin>https://some-example.com</AllowedOrigin>
<MaxAgeSeconds>3600</MaxAgeSeconds>
</CORSRule>
<CORSRule>
<AllowedHeader>Content-MD5</AllowedHeader>
<AllowedMethod>GET</AllowedMethod>
<AllowedOrigin>https://some-example.com</AllowedOrigin>
<MaxAgeSeconds>1800</MaxAgeSeconds>
</CORSRule>
</CORSConfiguration> Both payloads seem to be correct when looking at the AWS Docs at: https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutBucketCors.html#API_PutBucketCors_Examples |
@onno-vos-dev thank you for your reply. I will take a look at this and try it out based on your suggestions. I struggled to find documentation on how the parameters are passed. |
@zacksiri Have a look at: aws-beam/aws-codegen#109 and please comment if you'd find adding such specs would be helpful 👍 It should help clarify what is expected in terms of parameters. |
Closing due to stale issue. aws-beam/aws-codegen#109 should improve upon this situation as well and hopefully we can get this merged and into a new release in the coming week or so 👍 |
I'm trying to call the
put_bucket_cors
on theS3
module like so:I checked the built XML based on this request and i'm seeing:
Based on the documentation it seems this library isn't parsing the input correctly into xml it's leaving the plural form in the xml tag
The text was updated successfully, but these errors were encountered: