Error on uploading .json files

Hey! (:

I wish to upload some animation .json files on a field I created for a block. But I am receiving the error

animation-01.json
Invalid file type: code

The article below says that .json filetype are supported, but I could not make it work.

Is there anything I can do to make it work?

Thanks!

Here is my actual block blueprint:

title: Content Row
icon: book

fields:
headline:
label: Headline
type: writer
width: 1/2
subheadline:
label: Subheadline
type: writer
width: 1/2
animations:
label: Upload Animations
type: files

You need to assign a file blueprint in your section, and in that file blueprint, set the allowed file upload types by mime type or extension.

Thanks for the answer @texnixe

So I created a new blueprint inside of site/blueprint/files.

The file look like this.

allow-json.yml

title: JSON File

accept:
  mime: application/json
  extension: json

I understood it was all, but looks like not I as still have the same error.

I also tried with same results:

title: Allow All Files
accept: true

So now comes a few questions:

How to assign it in my section?
How can I assign it to a specific field at my page? as I wish to have another field that will receive just images (if possible)

Thanks!

See the second like I posted, please, here again the exact chapter: Files section | Kirby CMS

Right, so it is about the specify the template in the blueprint of my page. So I did, but still the error.

So I have until now:

site/blueprints/files/allow-json.yml

title: JSON File

accept:
  mime: application/json
  extension: json

site/blueprints/blocks/content-row.yml

title: Content Row
icon: book

fields:
  headline:
    label: Headline
    type: writer
    width: 1/2
  subheadline:
    label: Subheadline
    type: writer
    width: 1/2
 ...
  animations:
    label: Upload Animations
    type: files
    template: allow-json
...

I still got the same result. /:

I confess I get a bit lost with the documentation that I consider a bit unfriendly with beginners. I had the opportunity to read it throughly and if feels pretty complete, but the pieces sometimes don’t connect.

Is it possible to have an example considering my case?

Thanks a lot

That’s a field, not a section. So you need to set the uploads property instead of the template property, see Files | Kirby CMS

Perfect, it works! And thanks to guide me thought the documentation, I guess I would not be able to find it as it is hard to find something I didn’t know I was looking for :smiley: :wink:

As soon I make it work, I will post here the solution with example for people in the future that comes with the same question.

Here it goes the examples thanks the guidance of @texnixe :

site/blueprints/files/allow-json.yml

title: Allow json file

accept:
  mime: application/json
  extension: json

In my case I am adding the files to my home page through a custom block I created.

site/blueprints/blocks/content-row.yml

title: Content Row
icon: book

fields:
  ... (other fileds)
  animations:
    label: Upload Animations
    type: files
    uploads: allow-json  #Assuming that I have an allow-json.yml in site/blueprints/files
  ... (other fields)

At my specific case I am adding lottie animation .json files to my page. Here is how to bring it to my custom block:

site/snippets/blocks/content-row.php

 <div class="animation-wrapper">
        <?php if ($animation = $block->animations()->toFile()) : ?>
            <lottie-player class="animation" mode="normal" src="<?= $animation->url() ?>">
            </lottie-player>
        <?php endif ?>
  </div>

Enjoy!