Aliyun.Oss.Bucket.CORS (aliyun_oss v3.3.0)

Bucket operations - CORS.

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.

Functions

delete(config, bucket)

@spec delete(Aliyun.Oss.Config.t(), String.t()) ::
  {:error, Exception.t()} | {: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

iex> Aliyun.Oss.Bucket.CORS.delete(config, "some-bucket")
{:ok,
%Aliyun.Oss.Client.Response{
  data: "",
  headers: %{
    "connection" => ["keep-alive"],
    "content-length" => ["0"],
    "date" => ["Wed, 09 Jul 2025 07:31:57 GMT"],
    "server" => ["AliyunOSS"],
    "x-oss-request-id" => ["686E1AED****************"],
    "x-oss-server-time" => ["73"]
  }
}}

get(config, bucket)

@spec get(Aliyun.Oss.Config.t(), String.t()) ::
  {:error, Exception.t()} | {:ok, Aliyun.Oss.Client.Response.t()}

GetBucketCors - gets the cross-origin resource sharing (CORS) rules configured for a specific bucket.

Examples

iex> Aliyun.Oss.Bucket.CORS.get(config, "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: %{
    "connection" => ["keep-alive"],
    ...
  }
}}

put(config, bucket, config_xml)

@spec put(Aliyun.Oss.Config.t(), String.t(), String.t()) ::
  {:error, Exception.t()} | {:ok, Aliyun.Oss.Client.Response.t()}

PutBucketCors - configures cross-origin resource sharing (CORS) rules for a bucket.

Examples

iex> config_xml = ~S[
<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration>
...
</CORSConfiguration >
]
iex> Aliyun.Oss.Bucket.CORS.put(config, "some-bucket", config_xml)
{:ok, %Aliyun.Oss.Client.Response{
  data: "",
  headers: %{
    "connection" => ["keep-alive"],
    ...
  }
}}