MishkaCmsCore. Runtime. Resources. Changes. ProcessFileUpload
(Mishka CMS Core v0.0.1)
Copy Markdown
View Source
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, andrelative_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).nameandtypeare 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.