View Source BunnyCDN (bunny_cdn v0.1.0)
A simple HTTP Client for the Bunny Storage API.
Link to this section Summary
Functions
Delete directory or file at path from storage.
List or get file from storage.
Put files into the storage zone at the root level.
Put files into the storage zone at the defined path.
Link to this section Functions
@spec delete(BunnyCDN.Client.t(), String.t()) :: {:ok, term()} | {:error, Error.t()}
Delete directory or file at path from storage.
examples
Examples
client = Client.new("storage.bunnycdn.com", "my-sample-bunny-storage", "Sup3rsecretAPIkEy")
BunnyCDN.delete(client, "test/")
{:ok, %{"HttpCode" => 200, "Message" => "Directory deleted successfuly."}, %{status: 200}}
BunnyCDN.delete(client, "sample.mp3")
{:ok, %{"HttpCode" => 200, "Message" => "File deleted successfuly."}, %{status: 200}}
BunnyCDN.delete(client, "audio/sample.mp3")
{:ok, %{"HttpCode" => 200, "Message" => "File deleted successfuly."}, %{status: 200}}
BunnyCDN.delete(client, "audio/unknown.mp3")
{:error, %{status: 404}}
@spec get(BunnyCDN.Client.t(), String.t()) :: {:ok, term()} | {:error, Error.t()}
List or get file from storage.
examples
Examples
client = Client.new("storage.bunnycdn.com", "my-sample-bunny-storage", "Sup3rsecretAPIkEy")
BunnyCDN.get(client, "foobar/")
{:ok, [], %{status: 200}}
BunnyCDN.get(client, "audio/")
{:ok, [%{"Path" => "my-sample-bunny-storage/audio/"}], %{status: 200}}
BunnyCDN.get("audio/unknown.mp3")
{:error, %{"HttpCode" => 404, "Message" => "Object Not Found"}, %{status: 404}}
@spec put(BunnyCDN.Client.t(), Sting.t(), String.t()) :: {:ok, term()} | {:error, Error.t()}
Put files into the storage zone at the root level.
examples
Examples
client = Client.new("storage.bunnycdn.com", "my-sample-bunny-storage", "Sup3rsecretAPIkEy")
BunnyCDN.put(client, "./sample.mp3", "audio/sample.mp3")
{:ok, %{"HttpCode" => 201, "Message" => "File uploaded."}, %{status: 201}}
@spec put(BunnyCDN.Client.t(), Sting.t(), String.t(), String.t()) :: {:ok, term()} | {:error, Error.t()}
Put files into the storage zone at the defined path.
examples
Examples
client = Client.new("storage.bunnycdn.com", "my-sample-bunny-storage", "Sup3rsecretAPIkEy")
BunnyCDN.put(client, "./sample.mp3", "audio", "sample.mp3")
{:ok, %{"HttpCode" => 201, "Message" => "File uploaded."}, %{status: 201}}