New to Telerik UI for ASP.NET AJAX? Start a free 30-day trial
Using a Custom Content Provider
Using a Custom Content Provider
Starting from Q3 2011, RadImageEditor can use custom content providers. This ability will ease the usage of the control in CMS scenarios and its colaboration with RadFileExplorer where the content is stored in a DataBase, FTP or even an online storage system such as Amazon S3.
RadImageEditor is using the same abstract class, FileBrowserContentProvider, as RadFileExplorer and RadEditor for the custom content provider, which allows you to use already operational custom content providers without any modifications.
To configure RadImageEditor to use custom content provider you need to configure its ImageManager like follows:
C#
protected void Page_Load(object sender, EventArgs e)
{
string[] paths = new string[] {"~/Images"};
RadImageEditor1.ImageManager.EnableContentProvider = true;
RadImageEditor1.ImageManager.ContentProviderTypeName = typeof(Telerik.Web.Examples.DBContentProvider).AssemblyQualifiedName;
RadImageEditor1.ImageManager.ViewPaths = paths;
RadImageEditor1.ImageManager.DeletePaths = paths;
RadImageEditor1.ImageManager.UploadPaths = paths;
RadImageEditor1.ImageManager.SearchPatterns = new string[] { "*.jpg", "*.jpeg", "*.gif", "*.png", "*.bmp" };
}
ViewPaths, UploadPaths and DeletePaths for RadImageEditor's ImageManager should be set to the same path.
FileBrowserContentProvider Abstract Class Structure
C#
public class myNewProvider : Telerik.Web.UI.Widgets.FileBrowserContentProvider
{
//constructor must be present when overriding a base content provider class
//you can leave it empty
public myNewProvider(HttpContext context, string[] searchPatterns, string[] viewPaths, string[] uploadPaths, string[] deletePaths, string selectedUrl, string selectedItemTag)
: base(context, searchPatterns, viewPaths, uploadPaths, deletePaths, selectedUrl, selectedItemTag)
{
}
public override Telerik.Web.UI.Widgets.DirectoryItem ResolveRootDirectoryAsTree(string path)
{
throw new NotImplementedException();
}
public override Telerik.Web.UI.Widgets.DirectoryItem ResolveDirectory(string path)
{
throw new NotImplementedException();
}
public override string GetFileName(string url)
{
throw new NotImplementedException();
}
public override string GetPath(string url)
{
throw new NotImplementedException();
}
public override System.IO.Stream GetFile(string url)
{
throw new NotImplementedException();
}
public override string StoreBitmap(System.Drawing.Bitmap bitmap, string url, System.Drawing.Imaging.ImageFormat format)
{
throw new NotImplementedException();
}
public override string StoreFile(Telerik.Web.UI.UploadedFile file, string path, string name, params string[] arguments)
{
throw new NotImplementedException();
}
public override string DeleteFile(string path)
{
throw new NotImplementedException();
}
public override string DeleteDirectory(string path)
{
throw new NotImplementedException();
}
public override string CreateDirectory(string path, string name)
{
throw new NotImplementedException();
}
public override string MoveFile(string path, string newPath)
{
return base.MoveFile(path, newPath);
}
public override string MoveDirectory(string path, string newPath)
{
return base.MoveDirectory(path, newPath);
}
public override string CopyFile(string path, string newPath)
{
return base.CopyFile(path, newPath);
}
public override string CopyDirectory(string path, string newPath)
{
return base.CopyDirectory(path, newPath);
}
// ##############################################################################
// !!! IMPORTANT !!!
// The compilator will not complain if these methods are not overridden, but it is highly recommended to override them
public override bool CheckDeletePermissions(string folderPath)
{
return base.CheckDeletePermissions(folderPath);
}
public override bool CheckWritePermissions(string folderPath)
{
return base.CheckWritePermissions(folderPath);
}
//Introduced in the 2010.2.826 version of the control
public override bool CheckReadPermissions(string folderPath)
{
return base.CheckReadPermissions(folderPath);
}
// ##############################################################################
}