Aliyun.Oss.Bucket.CORS (aliyun_oss v2.0.0)
Bucket operations - CORS.
Link to this section Summary
Functions
DeleteBucketCors - disables cross-origin resource sharing (CORS) for a specific bucket and delete all CORS rules configured for the bucket.
GetBucketCors - gets the cross-origin resource sharing (CORS) rules configured for a specific bucket.
PutBucketCors - configures cross-origin resource sharing (CORS) rules for a bucket.
Link to this section Types
Link to this type
error()
Link to this section Functions
Link to this function
delete(config, bucket)
@spec delete(Aliyun.Oss.Config.t(), String.t()) :: {:error, error()} | {:ok, Aliyun.Oss.Client.Response.t()}
DeleteBucketCors - disables cross-origin resource sharing (CORS) for a specific bucket and delete all CORS rules configured for the bucket.
examples
Examples
iex> Aliyun.Oss.Bucket.CORS.delete("some-bucket")
{:ok,
%Aliyun.Oss.Client.Response{
data: "",
headers: [
{"Server", "AliyunOSS"},
{"Date", "Fri, 11 Jan 2019 05:19:45 GMT"},
{"Content-Length", "0"},
{"Connection", "keep-alive"},
{"x-oss-request-id", "5C3000000000000000000000"},
{"x-oss-server-time", "90"}
]
}}
Link to this function
get(config, bucket)
@spec get(Aliyun.Oss.Config.t(), String.t()) :: {:error, error()} | {:ok, Aliyun.Oss.Client.Response.t()}
GetBucketCors - gets the cross-origin resource sharing (CORS) rules configured for a specific bucket.
examples
Examples
iex> Aliyun.Oss.Bucket.CORS.get("some-bucket")
{:ok, %Aliyun.Oss.Client.Response{
data: %{
"CORSConfiguration" => %{
"CORSRule" => [
%{
"AllowedHeader" => "authorization",
"AllowedMethod" => ["PUT", "GET"],
"AllowedOrigin" => "*"
},
%{
"AllowedHeader" => "authorization",
"AllowedMethod" => "GET",
"AllowedOrigin" => ["http://www.a.com", "http://www.b.com"],
"ExposeHeader" => ["x-oss-test", "x-oss-test1"],
"MaxAgeSeconds" => "100"
}
],
"ResponseVary" => "false"
}
},
headers: [
{"Date", "Wed, 05 Dec 2018 02:34:57 GMT"},
...
]
}}
Link to this function
put(config, bucket, config)
@spec put(Aliyun.Oss.Config.t(), String.t(), String.t() | map()) :: {:error, error()} | {:ok, Aliyun.Oss.Client.Response.t()}
PutBucketCors - configures cross-origin resource sharing (CORS) rules for a bucket.
examples
Examples
iex> config_json = %{
"CORSConfiguration" => %{
"CORSRule" => [
%{
"AllowedHeader" => "Authorization",
"AllowedMethod" => ["PUT", "GET"],
"AllowedOrigin" => "*"
},
%{
"AllowedHeader" => "Authorization",
"AllowedMethod" => "GET",
"AllowedOrigin" => ["http://www.a.com", "http://www.b.com"],
"ExposeHeader" => ["x-oss-test", "x-oss-test1"],
"MaxAgeSeconds" => "100"
}
],
"ResponseVary" => "false"
}
}
iex> Aliyun.Oss.Bucket.CORS.put("some-bucket", config_json)
{:ok, %Aliyun.Oss.Client.Response{
data: "",
headers: [
{"Date", "Wed, 05 Dec 2018 02:34:57 GMT"},
...
]
}}
iex> config_xml = ~S[
<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration>
...
</CORSConfiguration >
]
iex> Aliyun.Oss.Bucket.CORS.put("some-bucket", config_xml)
{:ok, %Aliyun.Oss.Client.Response{
data: "",
headers: [
{"Date", "Wed, 05 Dec 2018 02:34:57 GMT"},
...
]
}}