# `ExOss.CDN.Behaviour`
[🔗](https://github.com/choice-form/ex_oss/blob/main/lib/ex_oss/cdn/behaviour.ex#L1)

Behaviour that all CDN adapters must implement.

Each CDN provider implements this behaviour to provide signed download
URLs and upload credentials. The dispatcher (`ExOss.CDN`) calls the
adapter module resolved from the client's `cdn.module` field.

## Implementing a New CDN Adapter

    defmodule MyApp.CDN.Aliyun do
      @behaviour ExOss.CDN.Behaviour

      @impl true
      def authorize_download_url(client, bucket, res_key, expires_in, opts) do
        # Generate a signed URL using Aliyun CDN's signing protocol
        ...
      end

      @impl true
      def upload_credential(client, bucket, res_key, expires_in) do
        %ExOss.UploadCredential{...}
      end
    end

Then register the adapter in `ExOss.Client` (the provider-to-module mapping).

# `authorize_download_url`

```elixir
@callback authorize_download_url(
  client :: ExOss.Client.Client.t(),
  bucket :: binary(),
  res_key :: binary(),
  expires_in :: non_neg_integer(),
  opts :: keyword()
) :: binary()
```

Generates a signed download URL for the given resource key.

# `upload_credential`

```elixir
@callback upload_credential(
  client :: ExOss.Client.Client.t(),
  bucket :: binary(),
  res_key :: binary(),
  expires_in :: non_neg_integer()
) :: ExOss.UploadCredential.t()
```

Generates upload credentials for the given resource key.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
