Closed domenico-barbieri closed 7 years ago
Can you provide a piece of code which produces this problem?
I've tried it with the following and couldn't reproduce the problem (on Nextcloud):
// Create WebDavSession
session.BaseUri = new Uri(@"http://mycloud.com/remote.php/webdav");
var items = await session.ListAsync("Test Folder");
I'm using the portable library in a Xamarin.Android project, logging to a Nextcloud server. Here it is some sample code:
var session = new WebDavSession(host, new System.Net.NetworkCredential(username, password));
session.BaseUri = new Uri(host + "/remote.php/webdav");
var items = await session.ListAsync("Test folder");
foreach(var item in items)
{
Debug.Write(item.Uri);
}
Running this test code in the OnCreate method of an Activity produce a list with the following item (the folder is empty): .../remote.php/webdav/Test folder/remote.php/webdav/Test%2520folder/
There is a problem with the class Uri
on Xamarin.
In order to cancat URIs, please use the class UriHelper
contained in the library. For more information about the PWL on Xamaran, please take a look at the wiki: https://github.com/DecaTec/Portable-WebDAV-Library/wiki/Xamarin
Yes, I also got the conclusion that the Uri class behaves differently between iOS/Android. The use of UriHelper
does not solve the issue. If I run the following code, the result is the same:
var session = new WebDavSession(host, new System.Net.NetworkCredential(username, password));
session.BaseUri = UriHelper.CreateUriFromUrl(UriHelper.CombineUrl(host, "/remote.php/webdav"));
var uri = UriHelper.CombineUriAndUrl(session.BaseUri, "Test folder");
var items = await session.ListAsync(uri);
foreach(var item in items)
{
Debug.Write(item.Uri);
}
OK, was able to reproduce the problem:
When having URLs with spaces and 'file' scheme (which seems to be a problem on Xamarin), Uri.AbsolutePath
messes up. So from test/test%20folder
, you'll receive test/test%2520folder
. This messes up all subsequent Uri/URL handling.
I was able to fix this with https://github.com/DecaTec/Portable-WebDAV-Library/commit/d8012cb86e783143c0144e6c4a00398388999988 by using the property Uri.LocalPath
instead.
I hope that this doesn't break anything on the iOS side...
I'll prepare an update for the library.
Released v1.0.1.0 - will be available on NuGet in a few minutes.
It looks working propely on Android, I'll test on iOS ASAP, thank you
It works correctly on iOS too.
Great! Thanks for the feedback.
If the requested folder path contains spaces, i.e. "Test folder", ListAsync returns the containing folder. Moreover, all the returned items have urls starting like that: "/remote.php/webdav/Test folder/remote.php/webdav/Test%folder/"