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

Schema for physical storage locations (redundancy tracking).

Tracks where each file instance is physically stored. Each instance can have
multiple locations for redundancy (1-5 copies across different buckets).

## Redundancy Example

If `storage_redundancy_copies = 2`, each file instance will have 2 location records:

    # Location 1: Backblaze B2
    %FileLocation{
      path: "/uploads/018e3c4a-9f6b-7890-thumbnail.jpg",
      status: "active",
      priority: 0,
      file_instance_uuid: "...",
      bucket_uuid: "018e3c4a-1111-7890-abcd-ef1234567890"
    }

    # Location 2: Cloudflare R2
    %FileLocation{
      path: "/uploads/018e3c4a-9f6b-7890-thumbnail.jpg",
      status: "active",
      priority: 0,
      file_instance_uuid: "...",
      bucket_uuid: "018e3c4a-2222-7890-abcd-ef1234567890"
    }

## Status Flow

- `active` - File is available at this location
- `syncing` - File is being uploaded/copied
- `failed` - Upload or sync failed
- `deleted` - File has been removed from this location

## Fields

- `path` - Full path within the bucket
- `status` - Current state of this location
- `priority` - Retrieval priority (0 = lowest, higher = preferred)
- `last_verified_at` - Last health check timestamp
- `file_instance_uuid` - Which instance this location stores
- `bucket_uuid` - Which bucket this file is stored in

## Examples

    # Active location on local storage
    %FileLocation{
      path: "/var/uploads/018e3c4a-9f6b-7890-large.jpg",
      status: "active",
      priority: 0,
      last_verified_at: ~N[2025-10-28 10:00:00],
      file_instance_uuid: "...",
      bucket_uuid: "018e3c4a-3333-7890-abcd-ef1234567890"
    }

    # Syncing to cloud backup
    %FileLocation{
      path: "/uploads/018e3c4a-9f6b-7890-large.jpg",
      status: "syncing",
      priority: 0,
      file_instance_uuid: "...",
      bucket_uuid: "018e3c4a-4444-7890-abcd-ef1234567890"
    }

# `t`

```elixir
@type t() :: %PhoenixKit.Modules.Storage.FileLocation{
  __meta__: term(),
  bucket:
    PhoenixKit.Modules.Storage.Bucket.t() | Ecto.Association.NotLoaded.t(),
  bucket_uuid: UUIDv7.t() | nil,
  file_instance:
    PhoenixKit.Modules.Storage.FileInstance.t() | Ecto.Association.NotLoaded.t(),
  file_instance_uuid: UUIDv7.t() | nil,
  inserted_at: DateTime.t() | nil,
  last_verified_at: DateTime.t() | nil,
  path: String.t(),
  priority: integer(),
  status: String.t(),
  updated_at: DateTime.t() | nil,
  uuid: UUIDv7.t() | nil
}
```

# `active?`

Returns whether this location is active and available.

# `changeset`

Changeset for creating or updating a file location.

## Required Fields

- `path`
- `file_instance_uuid`
- `bucket_uuid`

## Validation Rules

- Status must be valid (active, syncing, failed, deleted)
- Priority must be >= 0

# `deleted?`

Returns whether this location has been deleted.

# `failed?`

Returns whether this location has failed.

# `syncing?`

Returns whether this location is currently syncing.

---

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