> ## Documentation Index
> Fetch the complete documentation index at: https://docs.frogbot.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Files

> Mark one upload collection as FrogBot's file store.

FrogBot adds no files collection. Mark one upload collection with `file: true` to give pieces a place to store files. The collection appears under **Collections** in the admin panel and defines no custom fields unless you add them. FrogBot supplies upload metadata such as the filename, MIME type, size, and URL.

## Adopt your collection

Give one upload collection the `file: true` marker to use it as FrogBot's file store:

```ts theme={"theme":"tokyo-night"}
import type { CollectionConfig } from 'frogbot'

export const Files: CollectionConfig = {
  slug: 'files',
  file: true,
  fields: [],
}
```

That collection gets uploads, folders, soft deletion, admin list defaults, and access that requires an authenticated user. Your own fields, access rules, upload options, and other collection settings take precedence.

A larger example can set its own slug, upload options, and fields:

```ts theme={"theme":"tokyo-night"}
import type { CollectionConfig } from 'frogbot'

export const Documents: CollectionConfig = {
  slug: 'documents',
  file: true,
  upload: {
    mimeTypes: ['application/pdf']
  },
  fields: [
    { name: 'category', type: 'text' }
  ]
}
```

A collection marked `file: true` must not set `upload: false`. Mark only one collection as `file: true`. A collection cannot hold another FrogBot role, such as `chat: true`, at the same time.

## Folders

Files sit in folders. FrogBot adds a folders collection, `folders`, with a `name` field and `folders: true`, and gives the collection marked `file: true` a folder field, `_h_folders`, which the admin panel shows as a folder picker. Folders nest inside each other.

To use your own folders collection, set `folders: true` on it; FrogBot files into that one instead and doesn't add `folders`. Any other collection can file into it too:

```ts theme={"theme":"tokyo-night"}
import { createFolderField } from 'frogbot'
import type { CollectionConfig } from 'frogbot'

export const Pages: CollectionConfig = {
  slug: 'pages',
  fields: [{ name: 'title', type: 'text' }, createFolderField({ relationTo: 'folders' })],
}
```

## Storage

FrogBot stores uploads on local disk unless you configure a storage adapter. For production and serverless deployments, add an [upload storage adapter](https://docs.frogbot.ai/upload/storage-adapters.md) to `storage`. The adapter covers the collection marked `file: true`, if any, and `frogbot-chat-assets` when chat is enabled, automatically; you don't list them in the adapter's `collections`.

## Access

A collection marked `file: true` requires an authenticated user to create, read, update, or delete files unless you set your own `access` rules.

> [!WARNING]
>
> Files do not have per-user ownership or sharing rules. Authenticated users can access every file allowed by the collection's access rules.

## Keep existing files

FrogBot adds no files collection of its own. An app that stores files in `files` keeps them by declaring that collection with `file: true`:

```ts theme={"theme":"tokyo-night"}
import type { CollectionConfig } from 'frogbot'

export const Files: CollectionConfig = {
  slug: 'files',
  file: true,
  fields: [],
}
```

Without a marked collection, the next schema change in an existing app drops these tables:

* the `files` table;
* `folders`, when no other collection enables folders;
* `frogbot_trigger_subscriptions`, when no agent has a trigger or channel.

In development mode, schema push warns about the data loss and drops the tables only if you confirm. `frogbot migrate:create` writes the `DROP TABLE` statements into the migration for you to review before applying it. Stored files stay on disk or in the storage adapter, but no document references them anymore. On MongoDB the data stays, but FrogBot can't reach it.

## Piece output

[Pieces](https://docs.frogbot.ai/pieces/overview.md#file-output) that create files write to the collection marked `file: true`. Without one, those actions fail when they run:

```text theme={"theme":"tokyo-night"}
[frogbot] QR Code requires a files collection. Add an upload collection with `file: true`.
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.