# `MishkaCmsCore.Runtime.Resources.Changes.ProcessFileUpload`
[🔗](https://github.com/mishka-group/mishka_cms_core/blob/v0.0.1/lib/mishka_cms_core/runtime/resources/__changes/process_file_upload.ex#L5)

Processes uploaded file from consumed uploads and sets derived media attributes.

Supports both create and update actions:
- **Create**: requires at least one file, generates new UUID path via `save_file_to_storage`.
  Sets all file attributes: `name`, `type`, `size`, `format`, `relative_path`.
- **Update**: skips when no new file uploaded. When a new file is provided,
  replaces at the same path using backup/restore. Only updates `size`, `format`,
  and `relative_path` (path changes only when the file extension changes, or when the old path
  was not a file of the row's own site folder, which is never replaced).
  `name` and `type` are left to the user's form input.

Either way the entry's `path` must be a file a form's upload was staged as — see
`MishkaCmsCore.Runtime.Media.staged_upload/2` — or nothing is copied, replaced or deleted and the
action is refused: `media_files` reaches the action from the request as well, and the file it
names is removed once stored.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
