Search documentation of phoenix_kit

# PhoenixKitWeb.FileController (phoenix_kit v1.6.19)

View Source

File serving controller with signed URL support.

Handles secure file retrieval with token-based authentication and cache headers.

# Summary

## Functions

info(conn, map)

Get file information without serving the file.

show(conn, map)

Serve a file variant by ID with signed URL token.

# Functions

# info(conn, map)

Get file information without serving the file.

## Request

    GET /api/files/:file_id/info

## Response

Success (200):

    {
      "file_id": "uuid",
      "original_filename": "photo.jpg",
      "mime_type": "image/jpeg",
      "file_type": "image",
      "size": 1234567,
      "status": "active",
      "variants": [
        {
          "variant_name": "original",
          "mime_type": "image/jpeg",
          "size": 1234567,
          "width": 1920,
          "height": 1080,
          "url": "/file/uuid/original/token"
        }
      ]
    }

# show(conn, map)

Serve a file variant by ID with signed URL token.

## Request

    GET /file/:file_id/:variant/:token

## Parameters

- `file_id`: UUID of the file
- `variant`: Variant name (e.g., "original", "thumbnail", "medium")
- `token`: Signed token for authentication

## Response

Success (200):

- File streamed to client with appropriate headers:
  - `Cache-Control: public, max-age=31536000` (1 year)
  - `ETag: "md5-hash"`
  - `Content-Type: <mime-type>`
  - `Content-Disposition: inline; filename="..."`

Error (401):

    "Invalid or expired token"

Error (404):

    "File or variant not found"