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

# Interface: ActionFiles

> ctx.files in actions.

[server](/api/modules/server).ActionFiles

`ctx.files` in actions.

## Hierarchy

* `Pick`\<[`FilesWriter`](/api/interfaces/server.FilesWriter), `"grant"` | `"revoke"`>

  ↳ **`ActionFiles`**

## Methods

### grant

▸ **grant**(`file`, `options`): `Promise`\<[`FileGrant`](/api/modules/files#filegrant)>

Grant one recipient access to a protected file under current source
policy, until `expires_at` (epoch milliseconds). The recipient reads it
with the returned grant, itself a file locator. `request_key` makes a
retried grant return the grant it already issued.

#### Parameters

| Name | Type |
| :- | :- |
| `file` | [`AttachmentLocator`](/api/modules/files#attachmentlocator) \| [`FileRef`](/api/modules/values#fileref) |
| `options` | `Object` |
| `options.request_key` | `string` |
| `options.recipient` | `string` |
| `options.expires_at` | `number` |

#### Returns

`Promise`\<[`FileGrant`](/api/modules/files#filegrant)>

#### Inherited from

Pick.grant

***

### revoke

▸ **revoke**(`grant`): `Promise`\<`void`>

Revoke one grant: no new read is admitted through it. Other grants and
the stored bytes are unchanged.

#### Parameters

| Name | Type |
| :- | :- |
| `grant` | [`FileGrant`](/api/modules/files#filegrant) |

#### Returns

`Promise`\<`void`>

#### Inherited from

Pick.revoke

***

### open

▸ **open**(`file`, `options?`): `Promise`\<[`FileReader`](/api/interfaces/server.FileReader)>

Open a file's bytes for reading:
`await using reader = await ctx.files.open(attachment(document, "source"))`.
A protected attachment is read through its record and field, decided on
every open as delivery decides it, unless this action already admitted
it; a source-derived file keeps its retained source rules, and an
ordinary file needs no route.
`range` reads only the bytes `[start, end)`, which hold at least one
byte within the file. The read taints the action with the file's
protection: what the action publishes afterwards carries it.

#### Parameters

| Name | Type |
| :- | :- |
| `file` | [`AttachmentLocator`](/api/modules/files#attachmentlocator) \| [`FileRef`](/api/modules/values#fileref) |
| `options?` | `Object` |
| `options.range?` | `Object` |
| `options.range.start` | `number` |
| `options.range.end` | `number` |

#### Returns

`Promise`\<[`FileReader`](/api/interfaces/server.FileReader)>


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