provokateurin / dart-nextcloud

A Nextcloud client for dart
Other
20 stars 15 forks source link

Error when sharing a directory publicly #48

Open ElectrifyPowr opened 3 years ago

ElectrifyPowr commented 3 years ago

When I try to share a directory I get the following error:

Unhandled Exception: XmlParserException: "<" expected at 1:1
#0      new XmlDocument.parse (package:xml/src/xml/nodes/document.dart:35:7)
#1      sharesFromSharesXml (package:nextcloud/src/shares/share.dart:227:39)
#2      SharesClient.getShares (package:nextcloud/src/shares/client.dart:43:12)

My code:

// example of folderName: '/NewFolder'
Future<void> createShare(String folderNameToShare) {
  var ncClient = NextCloudClient.withCredentials(Uri(host: baseUrl), "my@email.com", "myPassword");
  await ncClient.webDav.mkdir(folderNameToShare);
  await ncClient.shares.shareWithPublicLink(folderNameToShare, permissions: Permissions([
        Permission.read, Permission.update
      ]));
}

The share url gets created on Nextcloud but the error as mentioned above occurs. What I also noticed is that even though I used permissions: Permissions([Permission.read, Permission.update]) for the shareWithPublicLink function, the folder in the end only has read permissions on Nextcloud.

The same error as mentioned above occurs when I try to get the share link:

List<Share> shares = await ncClient.shares.getShares(path: folderNameToShare);
if (shares.length>0) {
  print(shares.first.url);
}

Any help again will be very welcome.

trianglecirclexyz commented 2 years ago

Did you ever manage to figure it out? I've been running into the same issue.