Route does not fetch for file upload


I try to write a custom component for file upload in the panel.
I took the example from:

The upload button appears and works.
Uploading the file an error message is shown and claiming ‘No route found for path: “media/freePicturesPost” and request method: “POST”’.
Here is where the trouble starts.

I registered a routing:

Kirby::plugin('test/media', [
  'routes' => [
    'pattern' => '/api/media/freePicturesPost',
    'method' => 'POST',
    'action'  => function () {
      // do something

But it seems so be ignored.
What could be wrong?

Hello :slight_smile:

media/freePicturesPost is different from /api/media/freePicturesPost.

Your file upload (form?) action url is probably missing an /api/ at its beginning.

I tried all of theese so far:

  'pattern' => [

See here how to correctly register a custom API endpoint: API | Kirby CMS. I don’t think you can use media though.

I forgot to wrapt it inside ‘api’.
Thanx a lot!