# `PhoenixKit.Modules.Storage.Provider`
[🔗](https://github.com/BeamLabEU/phoenix_kit/blob/v1.7.87/lib/modules/storage/providers/provider.ex#L1)

Behavior for storage providers.

Each storage provider (local, S3, B2, R2) must implement this behavior
to provide file storage and retrieval capabilities.

# `delete_file`

```elixir
@callback delete_file(
  bucket :: PhoenixKit.Modules.Storage.Bucket.t(),
  file_path :: String.t()
) ::
  :ok | {:error, term()}
```

Deletes a file from the storage provider.

## Parameters

- `bucket` - The bucket configuration
- `file_path` - Path to the file in storage

## Returns

- `:ok` - File deleted successfully
- `{:error, reason}` - Failed to delete file

# `file_exists?`

```elixir
@callback file_exists?(
  bucket :: PhoenixKit.Modules.Storage.Bucket.t(),
  file_path :: String.t()
) ::
  boolean()
```

Checks if a file exists in the storage provider.

## Parameters

- `bucket` - The bucket configuration
- `file_path` - Path to the file in storage

## Returns

- `true` if file exists, `false` otherwise

# `public_url`

```elixir
@callback public_url(
  bucket :: PhoenixKit.Modules.Storage.Bucket.t(),
  file_path :: String.t()
) ::
  String.t() | nil
```

Gets a public URL for a file in the storage provider.

## Parameters

- `bucket` - The bucket configuration
- `file_path` - Path to the file in storage

## Returns

- Public URL string or `nil` if not applicable

# `retrieve_file`

```elixir
@callback retrieve_file(
  bucket :: PhoenixKit.Modules.Storage.Bucket.t(),
  file_path :: String.t(),
  destination_path :: String.t()
) :: :ok | {:error, term()}
```

Retrieves a file from the storage provider.

## Parameters

- `bucket` - The bucket configuration
- `file_path` - Path to the file in storage
- `destination_path` - Local path where to save the file

## Returns

- `{:ok, file_path}` - File retrieved successfully
- `{:error, reason}` - Failed to retrieve file

# `store_file`

```elixir
@callback store_file(
  bucket :: PhoenixKit.Modules.Storage.Bucket.t(),
  source_path :: String.t(),
  destination_path :: String.t(),
  opts :: keyword()
) :: {:ok, String.t()} | {:error, term()}
```

Stores a file in the storage provider.

## Parameters

- `bucket` - The bucket configuration
- `source_path` - Path to the source file on local filesystem
- `destination_path` - Relative path where to store the file
- `opts` - Additional options

## Returns

- `{:ok, url}` - File stored successfully, returns public URL
- `{:error, reason}` - Failed to store file

# `test_connection`

```elixir
@callback test_connection(bucket :: PhoenixKit.Modules.Storage.Bucket.t()) ::
  :ok | {:error, term()}
```

Tests the connection to the storage provider.

## Parameters

- `bucket` - The bucket configuration

## Returns

- `:ok` - Connection successful
- `{:error, reason}` - Connection failed

---

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