# Files on objects

AI agent getting started? Read [Agents: start here](https://docs.openeng.io/agents/start-here.md) first.

Add, view, replace, download and clear files on object properties.

Source: https://docs.openeng.io/guides/attachments/

Attach a file to an object property when the file belongs with that engineering record. You can do this in the object details panel or with the `openeng` CLI.

## Choose where the file belongs

A file is the value of a declared attachment property on an existing object. Use a drawing property on a Part, evidence on a Verification, or a PDF specification on a Requirement. The selected branch determines the version you are reading or replacing.

## Attach a file in the workspace

You need write access, an existing attachment field and a file within the per-file size limit.
The organisation's stored bytes must be below its storage limit when you open the upload.
The declaration's size does not change that storage admission answer within the per-file limit.
A PDF drawing, for example, needs a field that accepts PDFs. If there is no suitable field,
[add one to the type](#add-an-attachment-field-to-a-type) first.

1. Open the object details panel and find its attachment property.
2. Choose **Attach file**.
3. Choose a file whose type is accepted by the property.
4. In the **Reason for this change** field, write the reason like a commit message (see [Propose, compare and merge](https://docs.openeng.io/guides/change-control.md#develop-the-change)), then choose **Attach**.
5. Watch the committed bytes and total while the file uploads. You can choose **Cancel**; the
   drawer then shows **Cancelled**. A dropped connection resumes within the same upload.
6. Wait through **Saving…** for **Saved** before leaving the object.

The drawer shows **No file** when the property is empty. After an upload, it shows the file name and size. Choose **Download** to save a copy.

With read-only access, you can see the file name and size and download it; attach, replace and clear controls are hidden.

1. For `too-large`, choose a file within the per-file limit (1 GiB in production).
   For `storage-limit-reached`, ask an operator to review the organisation’s available storage.
2. If its content or extension is unsupported, choose a supported file and check that its name matches its type.
3. For `upload-not-found`, start the upload again. If your sign-in session ended, sign in again.

The platform calls unsupported extensions or content `unsupported-content`. A file on object creation
is refused with `attachment-requires-object`; create the object first, then attach the file.

See [Refusals](https://docs.openeng.io/reference/refusals.md) for other platform rejection reasons.

## Use the CLI

Use the project ID and the branch containing the object; the `--ref` flag takes the branch name. Get the object ID from a graph query; see [Query across relationships](https://docs.openeng.io/guides/graph-queries.md). The property key identifies where the file will be saved.

```sh
openeng attachment add <object-id> drawing ./drawing.pdf --project <project-id> --ref <branch> --reason "Attach the released drawing"
```

The `--reason` flag is required. Write it like a commit message, as [Propose, compare and merge](https://docs.openeng.io/guides/change-control.md#develop-the-change) teaches; the platform writes it first in the commit message, and the command refuses an empty reason before it sends anything.

The CLI uploads directly to the file store using lazy file reads and prints upload and download
progress to standard error. A dropped connection resumes from the store's committed offset within
the same call, with up to three resumes per piece. The SDK uses the same direct upload and accepts
`{ onProgress: (committed, total) => void }` as the third argument to
`uploadAttachment(selector, source, options)`. An open refused as `storage-limit-reached` sends no file bytes.

Start with a small PDF and an existing object whose published type declares `drawing` as a PDF attachment. Replace each placeholder with the returned ID or branch name. The command prints the attachment descriptor as JSON when it succeeds. List the object's attached files with:

```sh
openeng attachment list <object-id> --project <project-id> --ref <branch>
```

Download a file to its saved name, or choose a path with `--out`. The command writes the file as it arrives, checks it against the stored checksum, and keeps no partial file if the check fails. A large file is read from the platform's file store, not through the platform host:

```sh
openeng attachment get <object-id> drawing --out ./downloaded-drawing.pdf --project <project-id> --ref <branch>
```

Open the downloaded PDF and confirm it is the file you attached. See [CLI reference](https://docs.openeng.io/reference/cli.md) for command syntax and options.

## Replace or clear a file

1. To replace a file, choose **Replace file** in the drawer and select the replacement. In the **Reason for this change** field, write a commit-message reason (see [Propose, compare and merge](https://docs.openeng.io/guides/change-control.md#develop-the-change)), then choose **Replace**.
2. To remove the file from the property, choose **Clear**. In the **Reason for this change** field, write a commit-message reason (see [Propose, compare and merge](https://docs.openeng.io/guides/change-control.md#develop-the-change)), then choose **Clear**.
3. Wait for **Saved**, which confirms either change succeeded.

The CLI supports adding, listing and downloading attachments. It has no command to clear an attachment; use **Clear** in the workspace.

## View files

Object type views can show an STL mesh, an image or a PDF when configured for a matching attachment property. An image view needs alternative text. A STEP file can be downloaded, but the drawer does not preview it. A file larger than the viewer shows (images 50 MiB, PDFs 100 MiB, meshes 64 MiB) is not previewed: the panel shows the file name, its size and **Download**, and the file is not read until you choose **Download**. Large downloads are read directly from the file store.

## Add an attachment field to a type

1. Open a [type change set](https://docs.openeng.io/configure/types.md) to edit the object type.
2. Add a top-level property with kind `attachment` and an `accept` list of file classes. For example, `drawing: { kind: "attachment", accept: ["pdf"] }` accepts PDF files.
3. Publish the type change before attaching files to objects of that type.

Available classes are `image`, `pdf`, `step`, `mesh` and `text`. The accepted class also restricts the file's
extension and content. Images may be PNG, JPEG, WebP or GIF. Mesh files use STL; STEP files use `.step` or
`.stp`. Text includes formats such as TXT, Markdown, CSV, JSON and YAML. The host sets the per-file limit (1 GiB
in production); the organisation must also have storage available.

When the file is ready, [review the change on its branch](https://docs.openeng.io/guides/change-control.md) with the engineering record it supports.
