ThinDavApi
ThinDavApi is a small DAV client API based on MSXML.
Its main limitations are:
ThinDavApi refers to resources as "files" and collection resources as "directories" but this is merely an abstraction since they are really BLOBs of data. ThinDavApi can read/write binary data or UTF-8 text, handling text translation to and from Windows Unicode (UTF-16LE) via MSXML's facilities.
Purpose
ThinDavApi is meant to offer programmers a simple way to implement "cloud storage" within applications. There are many inexpensive and even free WebDAV hosting services you might use for a number of purposes. Examples might include submitting and/or retrieving updated data, remote logging, error reporting, and contact requests. This allows you to completely replace the use of SMTP email or FTP, both of which can suffer from insecure data transfer and firewall or ISP blocking problems. Very few firewalls will block WebDAV traffic over standard HTTP (port 80) or HTTPS (port 443).
ThinDavApi does not require any "web folder" setup and doesn't use any of the Microsoft WebDAV filesystem redirectors. When used with MSXML 3.0 which is perfectly adequate ThinDavApi can work on any version of Windows as far back as Windows 95. On an older OS you'd need to deploy MSXML 3.0 unless it was already installed by another product (e.g. IE 5.x). It is installed on every OS from a fully patched Win2k SP4 installation on up and is patched with bug fixes via Windows Update.
Some limited testing has been done using MSXML 6.0 but considering its deployment issues any advantages it offers probably don't warrant its use. However there might be a small performance boost in doing so as long as you only target systems where MSXML 6.0 is preinstalled or you are willing to deploy it (Win2K SP4 through WinXP SP2).
Aync Operation
Since the main reason for your programs to use WebDAV is to access a remote datastore over the Internet, synchronous operations aren't really practical. Because of this ThinDavApi does not support them.
All requests you make through ThinDavApi calls end by raising a Complete event. You can determine success or failure and retrieve results in your event handler.
Timeouts should be handled in your program using a timer of some kind. When a request takes too long you can call AbortRequest, and when Complete is subsequently raised you can test for the Aborted property.
Thin Wrapper
DAV is an XML-based protocol on top of HTTP.
ThinDavApi is a fairly thin wrapper on the MSXML library. Because of this request completion status information is reported as HTTP results (status code and status text) and some requests provide HTTP response headers after minimal parsing.
You don't need any XML knowledge to use ThinDavApi unless you need to do some advanced debugging or to add or modify features of ThinDavApi. Your best reference on DAV is probably RFC 2518, which covers all of the things ThinDavApi supports (and more).
Supported Resource Properties
ThinDavApi will make a PROPFIND request through its GetDir() method which returns:
The returned XML is parsed into a Variant property DirEntries. DirEntries is an array of Variant arrays, one row for the file or directory queried on and one row for each "child" resource unless the call specifies ChildInfo = False. Each column in these inner "DirEntry" arrays corresponds to one of the supported properties, translated to an appropriate Automation type (e.g. Date, Long, Boolean, or String in VB terms).
ThinDavApi also accepts an optional ContentType to use when creating a file by calling PutFileBytes() or PutFileText(), or if none is supplied a default is used.
Source Code, Usage
The ThinDavApi.cls module contains a block of comments describing its properties, methods, and events.
It has been provided here as part of a demo Project "ThinDAVMan" which makes use of most of its supported operations. In particular I've tried to show how to handle the async method calls and implement request timeouts using a Timer control. The ThinDAVMan.zip archive is attached to this post.
From Here
ThinDavApi 1.0 posted here was taken from another WebDAV client class that is at version 3.1, so it has had a lot of testing and debugging done already. However it may still have flaws including some that won't show up until somebody tries to use it with some server I haven't used yet. Despite the WebDAV standard I have found variations out there which required subtle workarounds.
The goal with ThinDavApi was to make a basic client that can be compiled into a VB6 program or used from VBA. This could also be the basis for a more complete WebDAV client that adds locking and other features, though at that point you may want to look at 3rd party commercial libraries that do a great job.
ThinDavApi is a small DAV client API based on MSXML.
Its main limitations are:
- No support for DAV resource locking.
- No partial-resource reading or writing, it deals with whole resources.
- No chunked transfer support, so it is better suited for smaller resources or situations where your application can afford the memory to hold a medium sized resource in memory.
- Only supports a few common resource properties, does not support modifying properties of existing resources.
ThinDavApi refers to resources as "files" and collection resources as "directories" but this is merely an abstraction since they are really BLOBs of data. ThinDavApi can read/write binary data or UTF-8 text, handling text translation to and from Windows Unicode (UTF-16LE) via MSXML's facilities.
Purpose
ThinDavApi is meant to offer programmers a simple way to implement "cloud storage" within applications. There are many inexpensive and even free WebDAV hosting services you might use for a number of purposes. Examples might include submitting and/or retrieving updated data, remote logging, error reporting, and contact requests. This allows you to completely replace the use of SMTP email or FTP, both of which can suffer from insecure data transfer and firewall or ISP blocking problems. Very few firewalls will block WebDAV traffic over standard HTTP (port 80) or HTTPS (port 443).
ThinDavApi does not require any "web folder" setup and doesn't use any of the Microsoft WebDAV filesystem redirectors. When used with MSXML 3.0 which is perfectly adequate ThinDavApi can work on any version of Windows as far back as Windows 95. On an older OS you'd need to deploy MSXML 3.0 unless it was already installed by another product (e.g. IE 5.x). It is installed on every OS from a fully patched Win2k SP4 installation on up and is patched with bug fixes via Windows Update.
Some limited testing has been done using MSXML 6.0 but considering its deployment issues any advantages it offers probably don't warrant its use. However there might be a small performance boost in doing so as long as you only target systems where MSXML 6.0 is preinstalled or you are willing to deploy it (Win2K SP4 through WinXP SP2).
Aync Operation
Since the main reason for your programs to use WebDAV is to access a remote datastore over the Internet, synchronous operations aren't really practical. Because of this ThinDavApi does not support them.
All requests you make through ThinDavApi calls end by raising a Complete event. You can determine success or failure and retrieve results in your event handler.
Timeouts should be handled in your program using a timer of some kind. When a request takes too long you can call AbortRequest, and when Complete is subsequently raised you can test for the Aborted property.
Thin Wrapper
DAV is an XML-based protocol on top of HTTP.
ThinDavApi is a fairly thin wrapper on the MSXML library. Because of this request completion status information is reported as HTTP results (status code and status text) and some requests provide HTTP response headers after minimal parsing.
You don't need any XML knowledge to use ThinDavApi unless you need to do some advanced debugging or to add or modify features of ThinDavApi. Your best reference on DAV is probably RFC 2518, which covers all of the things ThinDavApi supports (and more).
Supported Resource Properties
ThinDavApi will make a PROPFIND request through its GetDir() method which returns:
- Name - simple name of a file or directory. String.
- FullName - fully qualified path of a file or directory below the ThinDavApi BaseURL property. String.
- LastModified - timestamp. Date.
- ContentType - MIME type (only files). String.
- Length - in bytes at the server (only files). Long.
- IsFile - False for a directory and True for a file. Boolean.
The returned XML is parsed into a Variant property DirEntries. DirEntries is an array of Variant arrays, one row for the file or directory queried on and one row for each "child" resource unless the call specifies ChildInfo = False. Each column in these inner "DirEntry" arrays corresponds to one of the supported properties, translated to an appropriate Automation type (e.g. Date, Long, Boolean, or String in VB terms).
ThinDavApi also accepts an optional ContentType to use when creating a file by calling PutFileBytes() or PutFileText(), or if none is supplied a default is used.
Source Code, Usage
The ThinDavApi.cls module contains a block of comments describing its properties, methods, and events.
It has been provided here as part of a demo Project "ThinDAVMan" which makes use of most of its supported operations. In particular I've tried to show how to handle the async method calls and implement request timeouts using a Timer control. The ThinDAVMan.zip archive is attached to this post.
From Here
ThinDavApi 1.0 posted here was taken from another WebDAV client class that is at version 3.1, so it has had a lot of testing and debugging done already. However it may still have flaws including some that won't show up until somebody tries to use it with some server I haven't used yet. Despite the WebDAV standard I have found variations out there which required subtle workarounds.
The goal with ThinDavApi was to make a basic client that can be compiled into a VB6 program or used from VBA. This could also be the basis for a more complete WebDAV client that adds locking and other features, though at that point you may want to look at 3rd party commercial libraries that do a great job.