# file

File storage — write, read, readText, stat, delete and list.

```js
import { file } from 'wisp';   // async
```

```python
from wisp import file          # synchronous
```

Guide: [Files](/files).

## file.write(path, data, options?)

`data` is a string (stored as UTF-8) or bytes (JS: `Buffer`, `Uint8Array` or `ArrayBuffer`). The content type is guessed from the extension unless you pass one. Replaces an existing file. Returns `{ path, size, contentType, updatedAt }`.

```js
await file.write('exports/orders.csv', csv, { contentType: 'text/csv' });
```
```python
file.write("exports/orders.csv", csv, content_type="text/csv")
```

## file.read(path)

The contents as bytes (JS `Buffer`, Python `bytes`), or `null` / `None`.

## file.readText(path)

Python: `file.read_text(path)`. The contents as a string, or `null` / `None`.

## file.stat(path)

`{ path, size, contentType, updatedAt }` without downloading, or `null` / `None`.

## file.delete(path)

Deletes the file.

## file.list(options?)

| Option | Default | Description |
| --- | --- | --- |
| `prefix` | `""` | Only paths starting with this |
| `limit` | 100 | Maximum items |
| `cursor` | `null` | From the previous page |

Returns `{ items: [{ path, size, updatedAt }], cursor }`.

## Limits

Paths: no leading `/`, no `..`, up to 1,024 bytes. Files up to 25 MB. Responses are limited to about 6 MB.
