New file blueprint for gpx files


i want to use a individaul blueprint to upload gpx files (tracks form an GPS handheld). The mimetype is txt/xml and the fileextension is gpx

The href Problem is solved

I use this file: site/blueprints/files/gpx.yml

title: GPX
  mime: text/xml, application/gpx, application/gpx+xml
  extension: gpx

If I want to upload a new GPX file, the operating system only shows me XML files in the file selection. But I only want to see GPX files there.

What can i do?

Hi, and welcome to the forum :slight_smile:

I had the same issue and, after some research (IIRC, it has something to do with how the panel communicates the accepted MIME types to the browser…), got the file picker to cooperate by changing the file blueprint to:

title: GPX
  extension: gpx

(…omitting the mime option)

when I do it your way, the system shows all file types. After uploading, you get the error message that the wrong file type was selected.

Ah, sorry I forgot about that – while this change removes the limitation to XML files, I indeed never managed to get it to only show GPX files (which for example works fine when defining extension: doc, where the file picker filters neatly to “Word documents” only).

I believe this has to do with Kirby’s fallback, where the omission of the mime option reverts to the default MIME types hardcoded for that file ending. Since GPX is not defined in /src/Filesystem/Mime.php, it likely falls back to “all files”.

This is odd. I have been using this setting for many months and Kirby has happily digested dozens of GPX files with above setting :thinking: I wonder what is going on here…

From my experimentation last winter, I recall that the problem appears to be that GPX files are a special flavour of XML, which somehow leads to odd behaviour in the communication between the file upload dialog in the frontend (it happens in /panel/src/components/Sections/FilesSection.vue#L132, I believe), the file picker function of the browser and potentially the API of the operating system. As long as text/xml is present in the mime option, I cannot pick GPX files, and if I shorten the option to mime: application/gpx, application/gpx+xml I see all files of any type (probably the browser/OS APIs being unable to digest that more specific file type, as to them GPX files are text/xml) while uploads fail as the “true” MIME type is no longer in the list.

The workaround with showing all files was the best solution I could find back at the time, and for some reason I do not the error message you mention.

I had tried to benchmark some other sites that allow GPX uploads, and e.g. opens a file picker dialog that is limited to *.gpx files – but my JavaScript debugging skills are not on the level to assess how they achieved that.

sorry for the late reply. I was on holiday.
I think I expressed myself wrong. I only get the error message when I select a file other than gpx. It works well with gpx files. However, the selection in the dialog cannot be restricted.

The problem actually is here: kirby/files.php at 6b20fa11843f57cd9a1e611bc9e8e8a91b855156 · getkirby/kirby · GitHub
I’ve written a Pull Request that fixes this.
If that gets accepted, a blueprint like:

title: GPX
  extension: gpx

should limit the selection in the “file open dialog” to only .gpx files.

1 Like

Oh, thank you @rasteiner for identifying and suggesting this fix :rocket: