So, yeah, I’ve created a new blueprint
/site/blueprints/files/epub.yml with the following content:
I also have tried with the mime type:
files field I’m using:
But I’m still getting the following error:
What I’m doing wrong?
I suspect this is because Epub is not on Kirbys built in list of accpetable mime types.
* @copyright Bastian Allgeier
* @license https://opensource.org/licenses/MIT
* Extension to MIME type map
* @var array
public static $types = [
'ai' => 'application/postscript',
'aif' => 'audio/x-aiff',
'aifc' => 'audio/x-aiff',
'aiff' => 'audio/x-aiff',
'avi' => 'video/x-msvideo',
'avif' => 'image/avif',
'bmp' => 'image/bmp',
'css' => 'text/css',
'csv' => ['text/csv', 'text/x-comma-separated-values', 'text/comma-separated-values', 'application/octet-stream'],
'doc' => 'application/msword',
I think probably you would need to make a pull request or wait for the team to add it for you.
You can register custom file types:
File types | Kirby CMS
Oh neat didnt realise that got added to 3.6
Oh, that works fine! Now I can upload
epub files… although, now I have another issue. The
upload option correctly limits by mime type. But, when clicking on
select to select one from my already uploaded files, it let’s me select any file.
I suppose this is ripe for a GitHub issue? Or am I missing something?
You can limit what you can select in a field with a query, either by template (the template you assign to these epub files) or by file type or extension.
Files | Kirby CMS
Do you have an example at hand on how to filter by mime? or file template? I’ve tried the following but it’s not working:
query: page.files.filterBy('template', 'epub')
query: page.documents.filterBy('template', 'epub')
/blueprints/files/epub.yml file… that’s what
template means, no? My blueprints:
# Files field
Ok, this works:
query: page.documents.filterBy('extension', 'epub')
I find surprising that
template is not working though. It’s like it doesn’t know the type of template has each file… where is this info stored? In the
.txt file next to the file?
But do you assign this template anywhere in your files section?
should also work
I don’t know what you mean. I’m using
uploads: epub, which references to the
epub file blueprint. Isn’t that enough to tell it that the uploaded file is of that type?
Yes, sorry, didn’t look closely, thought you were uploading through a separate section not the field itself.
If all files have that template, then the query
For some reason that doesn’t work for me. I have a couple of upload fields, so maybe that’s why it isn’t working??
I was imagining that the “template” type information would be attached next to the file
.txt metadata. Or maybe it would be part of the file name… I don’t see neither of those.
The template is written in the file metadata file, exactly. Note that the template is only assigned at upload, not when you add files through the file system or added the
uploads: epub property later.