Project Description

VFS abstracts arbitrary hierarchical resources as a virtual file system, and provides access via a simple yet extensible and powerful API. As a true abstraction, it aims at solving a number of problems:
  • Truly transparent file access allows you to switch the used file system (e.g. from local storage to the cloud) without changing any code.
  • Custom authorization and authentication of file system requests based on your own business rules.
  • Custom providers can be easily implemented to expose any resources the way you want (e.g. virtual folders containing files depending on a user's identity)
  • Providers can define arbitrary meta data for files, folders, and permissions (e.g. to plug in quota management)
  • Seamless remoting of file systems if needed.
  • Reliable file transfers locally and over the wire with streamed and/or segmented down-/uploads.
  • Management and synchronization of concurrent read/write requests.
  • File event management (phase 2)

The most recent build can always be downloaded from here:
http://www.hardcodet.net/uploads/projects/vfs/vfs.zip

Editor's note: This project is currently in beta, so there's no production-ready content available here yet, but I'm grateful for feature requests and wish lists. I also plan to release updates and the first bits via http://www.hardcodet.net, so you can just subscribe to the blog's feed in order to keep up-to-date.



File System Providers

VFS's provider model abstracts hierarchical resources as a file model. Here's a few scenarios:

Provider Model.png



VFS 1.0 will come with a set of built-in providers, but hopefully, community contributions will be available as well. Currently planned providers:
  • Local File System, optionally limited to a given folder (implemented, see snippets below)
  • WCF/REST façade that allows to transparently access any VFS provider via a service interface (partly implemented, see snippet below)
  • Cloud Storage
  • FTP (priority 2)



Security

VFS will expose a pluggable security mechanism used for client authentication and authorization of file system requests. It will leverage the current offerings of the .NET framework, and also support Windows Identity Foundation (WIF) for service oriented scenarios.


Auditing

It is be possible to plug in an auditing manager which will receive auditing messages on configurable levels to simplify tracing and auditing of file system requests and incidents. A default auditing manager that just uses a logging mechanism will be part of the VFS core framework.


Clients

A set of clients will be provided that can be used as a starting point to integrate VFS into your applications:
  • RIA Client (Silverlight) using WCF
  • Desktop client (WPF) that uses different providers to access local or remote file systems.
  • ASP.net file download manager (operating on expiring download tokens)


The API

VFS is currently in early alpha but will hopefully progress fast enough so the first bits can be published. The client API, however, is already quite stable:

Every operation is an independent invocation on a file system provider (IFileSystemProvider interface):
//expose the contents of a given folder as a file system using a provider that operates on the local file system
IFileSystemProvider provider = new LocalFileSystemProvider(@"C:\MyData");

//we can get the root through its qualified name or a dedicated method (recommended)
VirtualFolderInfo root = provider.GetFileSystemRoot();
foreach (VirtualFileInfo file in provider.GetFiles(root))
{
  //access meta data
  Console.Out.WriteLine("Root folder contains file " + file.Name);

  //...read the file data (there's helper classes to deal with streams)
  Stream data = provider.ReadFileContents(file.FullName);

  //...or perform operations (delete, overwrite, move, copy)
  provider.DeleteFile(file.FullName);
}


Dealing with file system providers is greatly simplified through wrapper classes - VFS provides a very simple API to browse and manage the file system:
//get root folder
VirtualFolder root= VirtualFolder.CreateRootFolder(provider);
//create child folder on root level
VirtualFolder childFolder = root.AddFolder("folder1");

//upload a local file's data to the FS - overwrite it if it already exists
Stream stream = ...
VirtualFile file = childFolder.AddFile("foo.txt", stream, true);


This snippet gets text files in all folders on the root level and deletes them
VirtualFolder root= VirtualFolder.CreateRootFolder(provider);
foreach(VirtualFolder childFolder in root.GetFolders())
{
  foreach(VirtualFile file in childFolder.GetFiles("*.txt"))
  {
    VirtualFileInfo fileInfo = file.MetaData;
    Console.Out.WriteLine("Deleting file " + fileInfo.Name);
    file.Delete();
  }
}


VFS also comes with a WCF/REST service that service-enables arbitrary file system providers (just plug in a file system into the service). The service is complemented by a client library that is a VFS file system provider itself. Accordingly, the API is exactly the same when accessing remote data. The only change is the different provider implementation:

//the provider will access the service as configured in app.config
IFileSystemProvider provider = new RemoteServiceFileSystem();

//get root folder
VirtualFolderInfo root = provider.GetFileSystemRoot();

//create two folders on the root level
VirtualFolderInfo f1= provider.AddFolder(root, "folder1");
VirtualFolderInfo f2= provider.AddFolder(root, "folder2");

//copy the first folder into the second one (this operation will be performed on the server)
provider.MoveFolder(f1, "/folder2/copy");

Last edited May 14, 2010 at 11:04 AM by phsumi, version 20