tentwentyfour / nextcloud-link

Javascript/Typescript client that communicates with Nextcloud's WebDAV and OCS APIs
MIT License
57 stars 7 forks source link

webdav functionality requires a different url from pure nextcloud functionality #61

Open jcdufourd opened 3 months ago

jcdufourd commented 3 months ago

I have tried creating a folder then adding a share to it using nextcloud-link and it fails. The folder is not created and the share fails.

With the main url of the nextcloud server provided to the nextcloud-link client, adding a share on an existing folder works, but creating a folder does not.

If I add a folder with a generic webdav module, with the webdav-specific url provided in nextcloud files settings, it works.

The bug I suspect is that you need two different URLs in the client, one for webdav functionality and another for other functionality.

Using nextcloud 29

kwisatz commented 3 months ago

Hi @jcdufourd ,

Your assumption that two different endpoints (request paths) are responsible for creating a share and creating a directory is correct. The former uses the OCS API, while the latter uses WebDAV.

However, nextcloud-link should transparently use either one by passing just a single URL when initialising the client.

Could you please post a minimal failing example for what you're doing, so that we can try and reproduce your error?

jcdufourd commented 3 months ago

import NextcloudClient from "nextcloud-link"; … const client = new NextcloudClient( { "url": "https://myservername:33333/", "username": “myadmin”, "password": “pw” }); … // GroupFolders exists as a folder in the root directory of the myadmin user await client.createFolderHierarchy('GroupFolders/'+nextcloudgroupname); // does nothing, no error, folder not created await client.touchFolder('GroupFolders/'+nextcloudgroupname); // does nothing, no error, folder not created … // if I create the folder in the web interface await client.shares.add('GroupFolders/'+nextcloudgroupname, 1, "leaders", 31); // works perfectly

And then: await client.touchFolder(‘/GroupFolders/'+nextcloudgroupname); // works await client.shares.add(‘/GroupFolders/'+nextcloudgroupname, 1, "leaders", 31); // works

What was confusing me is the fact that client.shares.add works with path without initial /, and touchFolder does not.

It is not a bug, just a minor inconvenience to maybe document.