This lose series of articles will cover the implementation of a file system façade that allows transparent remote file system access in VFS.
The series will cover the following topics:
- Introduction and basic concept (this article)
- Implementing a RESTful file system proxy service with OpenRasta (coming soon)
- Unit testing the OpenRasta proxy service (not yet published)
- General tutorial: Streaming binary data in Silverlight
- Implementing VFS client libraries for both .NET and Silverlight (not yet published)
VFS File System Providers
VFS abstracts access to arbitrary file systems through so-called “File System Providers”, which expose a common interface (IFileSystemProvider) that allows you to browse and modify the file system. The interface is not exactly lean, but easy to understand:
Now, common file system providers directly operate on some kind of hierarchical data. Here’s a few examples:
- The “Local File System Provider” allows you to access your local machine, or the contents of a dedicated directory.
- The “ZIP File System Provider” works upon a single ZIP file, and allows you to transparently access and modify its contents.
- An “FTP File System Provider” connects to a given FTP server and gives you access to the server’s files through the VFS API.
So basically, an application uses a VFS provider, which in turn directly accesses the exposed file system:
There is, however, a special family of file system providers that do not access any files. Instead, they forward file system requests to another file system provider, thus creating a tunnel to another file system. Basically, these file system providers are façades to another, arbitrary file system provider.
Here’s an exemplary scenario that uses a façade in order to access a ZIP file that is exposed through a ZIP file provider (click on the UML diagram in order to see it in full size).
The interesting point here: From the client’s perspective, there is no difference in accessing the file system. The façade itself implements the IFileSystemProvider interface – it provides exactly the same API as any other provider.
As you can see from the diagram above, a façade is usually complemented by some kind of proxy that receives the forwarded requests, so in order to implement the pattern, there’s two components to be written:
- The façade, which implements IFileSystemProvider.
- The proxy that takes the forwarded requests, forwards them its own file system provider, and eventually returns the requested data. This proxy is not a VFS component, and you don’t have to implement any VFS interfaces.
As you can guess, tunnels come in handy in order to access remote data. Here’s a few scenarios:
- Run a local file system provider on a server that provides a download service. Clients don’t have direct access to the files, but use a tunnel to access the files that are exposed through the provider that runs on the server.
- Allow a Silverlight client to browse the contents of a ZIP file on the server, without having to download the whole ZIP file first (sample coming).
- Host a cloud file system provider within a WCF service, and expose parts of the cloud’s data to clients. Like this, clients don’t have direct access to the cloud data.
A RESTful Façade Implementation
Every façade itself is an independent file system provider – so tunneling is rather a pattern than an API, and you can write your own façade should you wish to (actually, contributions will be most welcome!).
However, VFS 1.0 will ship with a single façade implementation that uses HTTP/REST to create a tunnel to a remote file system. It is built upon the following libraries:
- On the server side, OpenRasta was used to expose file system access as RESTful services. OpenRasta is a lightweight, but powerful framework that comes with a API.
- On the client side, the WCF REST Starter Kit was used for both .NET and Silverlight clients (the Silverlight library hacked together by myself). The starter kit’s client libraries allow for simple access to RESTful resources, even if there is no WCF involved.
The upcoming articles will walk you through the implementation of the both the client and service libraries, and will also be complemented by a preview release of VFS. Stay tuned