Database File Provider

Custom FileBrowserContentProvider implementation allows using virtually any type of file sources for the FileBrowser dialogs (Image Manager, DocumentManager, Media Manager, Flash Manager, Template Manager):

- Database
- Custom role-based CMS system
- Web service
- Applications which use URL Rewriters

This example demonstrates the implementation of a custom FileBrowserContentProvider, using a database as a file source.

The DBFileBrowserContentProvider class inherits the abstract Telerik.WebControls.RadEditorUtils.FileBrowser class and implements several of its abstract members. These are:

- ResolveRootDirectoryAsTree - called when a FileBrowser dialog is opened in tree mode (the default mode). When building the content tree, the items which are parents of the SelectedUrl property value must be loaded. This should be done to have the FileBrowser positioned to the correct folder after an upload/delete/directory creation is done.
- ResolveRootDirectoryAsList - called when a FileBrowser dialog is opened in list mode (by clicking on the ListMode icon)
- ResolveDirectory - called when entering a subdirectory for the first time - by making an AJAX call
- StoreFile - called to save an uploaded file to the storage
- DeleteFile - called when user deletes a file
- DeleteDirectory - called when user deletes a directory
- CreateDirectory - called when user creates a directory
- CanCreateDirectory - a readonly property, which value identifies if the New Directory icon will exist in the FileBrowser
- GetFile - used in two cases: 1) to identify if a file with the same name exists in the same path when uploading a file; 2) when creating a thumbnail used to get the original image content
- StoreBitmap - used to save a newly created bitmap to the storage
- GetFileName - used to return the name of a file with given URL
- GetPath - used to return the path of an item (file or directory) with given URL

DBFileBrowserContentProvider uses a helper DataServer class, designed to handle the database operation functions.

The file content is stored in the database and is served by the content-streamer Handler.ashx file.