Register/open custom file extension/ending

Hello,

i want to develop an app, that can open files with a custom file extension/ending. When someone clicks on a file in nextcloud files with that extension, it should open the file in a 3D Viewer (that i already have). What i would also need, is the header of the file, to display various informations.

I have setup the basic app structure from the tutorials. My first goal is now to have my mime type recognized and my app set as default. I have now come across registerFileAction:

My question would be, if registerFileAction can handle my first goal.

Here is my app.php

<?php
namespace OCA\SamoViewer\AppInfo;

use OCP\AppFramework\App;
use OCP\Util;

class Application extends App {
    public function __construct(array $urlParams = []) {
        parent::__construct('samoviewer', $urlParams);

        Util::addScript('samoviewer', 'extension');
    }
}

Now i can see in my browser, that the extension gets loaded, but i am not sure how to use the registerFileAction or if i should use something else.

Can someone tell me, if i am on the right path with registerFileAction or do i need something else to get my mimetype registered and my app set to default?

I would be very grateful for any examples/explanations/links/help.

thank you!
kind regards Christoph

Hi @Christophs , did you had a look on GitHub - WARP-LAB/files_3dmodelviewer: 3D Model Viewer for Nextcloud ? This app seems to matchs either your needs either you can see quite the same developer use cases.

Thank you for your answer!

I have already looked at the app. Since I am a beginner, it is/was a bit overwhelming. So I thought that for my project registerFileAction might be good to start with.

The usecase seems to be pretty much the same, except it should read more from my custom file type and then process/display that data in the viewer.

I will have another look and try to filter out the things I would need to register the data type and be able to open it with my app.