WebDAV Drive Sample for iOS in .NET, C#
This sample implements a virtual file system for iOS that displays documents from a WebDAV server. It supports synchronization, on-demand loading and selective offline files support. This sample is written in .NET, C#.
This sample is supplied as part of the SDK with IT Hit WebDAV Client Library for .NET and with IT Hit User File System.
You can download this sample and trial licenses in the IT Hit WebDAV Client Library product download area and in the IT Hit User File System product download area. You can also clone it or browse the code on GitHub.
This sample is provided with IT Hit User File System v8.1 and later versions.
Note that you MUST complete all steps described in the macOS File Provider Extension Projects Deployment article.
Requirements
- This project requires physical device. It can not run on simulator.
- .NET 8
- Xcode 14.3+
- Visual Studio Community 2022 for Mac, Stable Channel.
Server Requirements
This sample requires WebDAV server with collections synchronization support. The following samples support collections synchronization:
- FileSystemSynchronization sample supplied with IT Hit WebDAV Server Engine for .NET.
- collectionsync sample supplied with IT Hit WebDAV Server Library for Java.
You can also test this sample with IT Hit demo servers:
Setting License
Note that to use the sample you need both the IT Hit WebDAV Client Library license and IT Hit User File System license.
To run the example, you will need both IT Hit WebDAV Client Library for .NET license and IT Hit User File System Engine for .NET License. You can download a WebDAV Client for .NET trial license in the IT Hit WebDAV Client Library product download area and the User File System trial license in the IT Hit User File System product download area. Note that this sample is fully functional with a trial licenses and does not have any limitations. The trial licenses are valid for one month will stop working after this. You can check the expiration date inside the license file. Download the license files and specify license strings in the WebDAVClientLicense and UserFileSystemLicense fields respectively in WebDAVMacApp\Resources\appsettings.json file. Set the license content directly as a value (NOT as a path to the license file). Do not forget to escape quotes: \":
"UserFileSystemLicense": "<?xml version=\"1.0\" encoding=\"utf-8\"?><License…
You can also run the sample without explicitly specifying a license for 5 days. In this case, the Engine will automatically request the trial licenses from the IT Hit website https://www.userfilesystem.com. Make sure it is accessible via firewalls if any. After 5 days the Engine will stop working. To extend the trial period you will need to download trial licenses and specify them in appsettings.json
Setting WebDAV Server URL
To specify the WebDAV server URL edit the "WebDAVServerUrl" parameter in appsettings.json. This could be either a server root path (https://server/) or a WebDAV folder on your server (https://server/dav/).
For testing and demo purposes you can use one of the IT Hit demo servers. Navigate to https://webdavserver.net or to https://webdavserver.com in a web browser. Copy the URL or your test folder, that looks like https://webdavserver.net/User123456/ and specify it in the WebDAVServerUrl parameter.
"WebDAVServerUrl": "https://webdavserver.net/User123456",
Setting Web Sockets Server URL
The client application receives notifications from server about changes via web sockets. To specify your web sockets server URL edit the "WebSocketServerUrl" parameter in appsettings.json.
In case you are using IT Hit demo servers, you will specify the demo server root, without user folder: wss://webdavserver.net or wss://webdavserver.com.
"WebSocketServerUrl": "wss://webdavserver.net"
Running the Sample
Note that you MUST complete all steps described in the macOS File Provider Extension Projects Deployment article.
To run the sample:
- Open the project in Visual Studio and run the project. The application is added to the macOS Status Bar.
- Select 'Install Extension' command in the Status Bar. This will mount your WebDAV file system.
Now you can manage documents using Finder, command prompt or by any other means. You can find the new file system in the 'Locations' sections in Finder.
For the development and testing convenience, when installing the extension, it will automatically open an instance of Finder with a mounted file system as well as will launch a default web browser navigating to the WebDAV server URL specified in your appsettings.json: