Auto-Assign file blueprints based on file-type

Hi,
I’m trying to auto-assign file blueprints based on the file type that was uploaded. I am aware that I can restrict what can be uploaded using the uploads: blueprint option, that is not what I am trying to accomplish—and I already use that wherever applicable.

What I want to accomplish is this:
I want to allow uploads of any kind, and if the uploaded file is an image, I want Kirby to auto-assign it the file-blueprint “image”. If the user uploads a PDF, docx, pages, etc. file, I want Kirby to auto-assign the blueprint “document”. For csv, xlsx, etc. I want to assign “spreadsheet”. And so on.

Is there any simple way to assign specific extensions or MIME-types to file-blueprints in Kirby? I know file-blueprints have the accept: xyz option, but that only restricts, it doesn’t lead Kirby to auto assign the blueprint to all applicable files upon upload.

Thanks in advance!

The only way to achieve this (i.e. assign a blueprint based on file type), would be via a file.create.after hook: file.create:after | Kirby CMS

1 Like