How to access OCA.Files JavaScript APIs in Nextcloud 28?

Hi everyone,
I am the developer of the HEIC/ HEIF Image Converter app and currently try to port it to Nextcloud 28, since I noticed that this time a simple version bump is not enough to get it running again.

In this application, I make heavy use of methods/ properties from the OCA.Files namespace, and it seems like using those is more or less deprecated.
As far as I am concerned, “modern” apps should use the methods of the separate NPM module: @nextcloud/files
While this approach seems to be working fine to register file actions I noticed that it doesn’t give me the same parameters in the handler.

Especially, I am missing the “context” parameter that was present on the legacy (?) OCA.Files.FileAction.registerAction() method’s “action” handler signature.
I used this context object to set the busy state of the files (context.fileList.showFileBusyState()) and trigger a reload (context.fileList.reload()) once my action was completed.
I guess that this is just not yet part of the new API, or am I missing something?
Maybe even out of scope for the NPM modules, because it’s too low level? I don’t know…

Anyway, the real problem that I have is that even once the whole Nextcloud website finished loading, I don’t have access to the old OCA.Files.App and OCA.Files.fileActions APIs anymore.
The only thing that is returned is this:

This is of course just a fraction of the old OCA.Files APIs.

Is this a bug, or am I doing something wrong here?
As you can see in my test case I am using the browser console, once everything has finished loading, but I also tried to access them from within my app, both using Util::addInitScript and Util::addScript.
In both cases the results were the same.

Edit: I am using Nextcloud 28.0.3 RC1 for my development setup.

Oh okay seems like i missed this part of the changelog. Thanks for the hint.
I think that’s a pretty drastic change, especially since those APIs weren’t deprecated before.

So what is the suggested alternative to set the busy state of a file or reload the fileList?
Is there any?

I’m not aware of a public API for that.

Oh wow I am really surprised and disappointed by that.
I had hoped that the existing public APIs had only been moved to a new repository, not completely removed without any deprecation notice before.

Is there any chance that a feature request to add those APIs to the new modules would be accepted?

I guess the only alternative that I have otherwise is to completely reload the page whenever I add a new file on the server side, right?

I am not a Files developer. An API might still exist, I’m just not aware of it.

Okay then I hope that somebody of the Files team might read this as well.
Or should I create an issue on Github for this?

You might want to ask your question here: Maybe someone there can help you!

Sorry, I think you need to be logged in to see the room.

Okay thank you, but how can I register for this Nextcloud instance?
I don’t see any button to do so.

Please ask in the community chat Nextcloud. If this does not work out, we might be able to ping persons directly.

All right thank you :slight_smile:

OCA is never public API but private API of the app, only OCP is considered public (thats what the P stands for) and will get proper deprecation.

So what is the suggested alternative to set the busy state of a file or reload the fileList?

Currently available API is this one:

You can interact with the files list using the Nextcloud eventbus and following events:

  • files:node:created → Add a new node without need of reload
  • files:node:deleted → Delete a node from the list
  • files:node:updated → Update a node

All that events take a node as the parameter see the @nextcloud/files documentation for the Node class interface. Those events will then update the files list view.

And also OCP.Files.Router with:

* Trigger a route change on the files app
* @param path the url path, eg: '/trashbin?dir=/Deleted'
* @param replace replace the current history (default false)
* @see
goTo(path: string, replace?: boolean): Promise<Route>;
 * Trigger a route change on the files App
 * @param name the route name
 * @param params the route parameters
 * @param query the url query parameters
 * @param replace replace the current history
 * @see
	name?: string,
	params?: Record<string, string>,
	query?: Record<string, string | (string | null)[] | null | undefined>,
	replace?: boolean,
): Promise<Route>;
1 Like

Hello @susnux ,
Thanks for the clarification about the OCA namespace, I didn’t know about it.
I will see how far i get with the current eventbus and router implementation and report when I’m done.

Same your question, how can i can create a button or other view when api OCA.Files remove in version 28. :smiling_face_with_tear:

Are you really searching for the same feature as the original poster? If yes, all right, go ahead. If no, please open a new topic (possibly adding a link to this topic) to keep concerns separated.

Side question:
Where should the button be? What is a view in your terms?

thanks u, after researching, i think i did it, based on recommendations app in github,
First time I try search at docker code mount in folder, but it is so hard.
After searching, I found solution at app recommendations github, I created button at headers

Follow up: I have found some problems using the event-bus approach and created an issue on Github for this: Emit files:node:created from FileStat object from WebDAVClient.stat() doesn't work · Issue #919 · nextcloud-libraries/nextcloud-files · GitHub

Hi @susnux :slight_smile:

Thanks for this direction :pray:

I don’t see a wiki and I don’t find a documentation on the Nextcloud developer documentation — Nextcloud latest Developer Manual latest documentation .

Is there any documentation on this lib ?

The link that he posted is basically the documentation, even tho it’s not very extensive especially when it comes to the different event types.

Yes, of course. But, I can’t figure out how to register my plugin with FileList from OCA.Files :thinking:

OC.Plugins.register('OCA.Files.FileList', MyPlugin);

Besides, when I read this documentation, I think it’s no longer possible because all API are removed except Sidebar and Settings, right ?