# Uploaded Files

FlexUploader registers a **custom post type (CPT)** called **Uploaded Files** to track every file that passes through the plugin. Each time a file is successfully uploaded and stored at its destination, a corresponding Uploaded Files entry is created automatically.

## Accessing Uploaded Files

Uploaded Files entries appear in the WordPress admin sidebar under **Uploaded Files**. From here you can:

- Browse all files that have been uploaded through the plugin.
- View the file details (original name, MIME type, size, storage destination).
- Open a secure preview/download link for the file.
- Filter and search by taxonomy (tag, directory, or file type).

## File Details

Each Uploaded Files entry includes a **File Details** meta box with the following information:

| Field | Description |
|-------|-------------|
| Original Filename | The filename as the user uploaded it. |
| MIME Type | The detected content type (e.g. `video/mp4`, `image/jpeg`). |
| File Size | Size of the file in bytes. |
| Stored Filename | The name used on disk (or the S3 object key). Randomised for local storage to prevent enumeration. |
| Destination | Where the file is stored (`file`, `s3`, or `media_library`). |
| View File | A secure link to stream or download the file. |

## Taxonomies

Uploaded Files entries are organised using three taxonomies:

### Upload Tag

A flat (non-hierarchical) taxonomy for general-purpose tagging. Use tags to label files with descriptive keywords across any category.

### Upload Directory

A hierarchical taxonomy that mirrors the directory tree the user organised their files into at upload time. This allows you to browse uploaded files by folder, just as you would in a file system.

### Upload File Type

A flat taxonomy for classifying files by their intended use within your application (e.g. `profile_picture`, `certification`, `drone_picture`). Source Types are associated with a file type term, so uploads are automatically categorised.

## Viewing and Streaming Files

Files are not served directly from the filesystem. Instead, the plugin provides a secure endpoint that:

1. Validates the request with a nonce.
2. Confirms the requesting user is the file's owner or an administrator.
3. Streams the file with proper HTTP headers.

For video and audio files, the endpoint supports **HTTP Range requests**, allowing media players to seek within a file without downloading it entirely.

The **View File** link in the File Details meta box generates a correctly authenticated URL for the currently logged-in admin user.

## Relationship to Destinations

- **Local File Storage** — The stored filename on disk is a randomised string. The original filename is preserved in the `Original Filename` meta field.
- **WordPress Media Library** — An attachment is created in the Media Library. The Uploaded Files CPT entry links to it.
- **Amazon S3** — The stored filename is the full S3 object key. Files are streamed from S3 through the secure endpoint.

## S3 Downward Sync

When a destination has **Downward Sync** enabled, the plugin scans the configured S3 bucket and creates Uploaded Files entries for any objects not already tracked. This allows you to import files that were uploaded to S3 outside of FlexUploader (e.g. via the AWS console or another tool). Sync can be filtered by file extension using the **Sync File Types** field on the destination.
