Thx
Scott
9 Answers, 1 is accepted
RadEditor Prometheus does not expose such event. If you need to execute custom code when a file is uploaded, you could inherit a class from Telerik.Web.UI.Widgets.FileSystemContentProvider, override the StoreFile method and execute your custom routine there. Please, let me know if you need a sample and we will provide you with one.
All the best,
Valeri Hristov (Senior Developer, MCSD)
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
Yes, could you provide a sample.
Thanks.
Scott
Please, find attached the requested sample. Let me know how it goes.
All the best,
Valeri Hristov (Senior Developer, MCSD)
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
I did it just like the example you sent and I am getting the following error:
Error 41 No overload for method 'FileSystemContentProvider' takes '0' arguments
Below is the relevant code.
Thanks.
Scott
public class CustomContentProvider : Telerik.Web.UI.Widgets.FileSystemContentProvider
{
public override string StoreFile(Telerik.Web.UI.UploadedFile file, string path, string name, params string[] arguments)
{
string targetFullPath = Path.Combine(path, name);
if (File.Exists(targetFullPath))
{
File.Delete(targetFullPath);
}
//Instead of saving the image file, you could execute
// your routine for decreasing its dimensions.
//file.SaveAs(Context.Server.MapPath(targetFullPath));
if (targetFullPath.ToUpper().EndsWith(".JPG") || targetFullPath.ToUpper().EndsWith(".GIF") || targetFullPath.ToUpper().EndsWith(".PNG") || targetFullPath.ToUpper().EndsWith(".BMP"))
{
//string originalImageLocation = Server.MapPath(fileName);
Bitmap bmp = CreateThumb(targetFullPath, 500, 500);
//Delete the original bitmap
File.Delete(targetFullPath);
//Save new bitmap using the same name
bmp.Save(targetFullPath, System.Drawing.Imaging.
ImageFormat.Jpeg);
bmp.Dispose();
}
//You have to return the full path of the saved file here
return targetFullPath;
}
}
protected void Page_Load(object sender, System.EventArgs e)
{
txtEditor.ImageManager.ContentProviderTypeName = typeof(CustomContentProvider).AssemblyQualifiedName;
EditorSetup();
}
You can download an example demonstrating how to create a DBFileBrowserContentProvider with RadEditor "Prometheus" from here: DBFileBrowserContentProvider.zip. Please, test it and let me know if you still experience the problem.
The example should be tested on IIS, but not on Cassini (the web development server of Visual Studio).
Kind regards,
Rumen
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
It appears to use this I will need to rewrite all of the methods in the FileBrowserContentProvider class. Is that true? All I really need to do is override the StoreFile method with my routine that resizes the image. Do you have an example that is file system-based and not database-based, because based upon the DB sample I will need to rewrite the View Files methods too even though the native ones work fine.
Thanks.
Scott
Yes, it is possible to override only the StoreFile method. However, your provider needs to need to inherit from the existing editor file system provider instead of the generic file browser provider. Here is some sample code:
| public class CustomEditorFileProvider : Telerik.Web.UI.Widgets.FileSystemContentProvider |
| { |
| public override string StoreFile(UploadedFile file, string path, string name, params string[] arguments) |
| { |
| string fileName = base.StoreFile(file, path, name, arguments); |
| //create thumbnail here |
| // |
| return fileName; |
| } |
| } |
All the best,
Lini
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
A colleague noted that the above code will not compile since you also need to define a constructor. I am posting the updated snippet here:
| public class CustomEditorFileProvider : Telerik.Web.UI.Widgets.FileSystemContentProvider |
| { |
| public CustomEditorFileProvider(HttpContext context, string[] searchPatterns, string[] viewPaths, string[] uploadPaths, string[] deletePaths, string selectedUrl, string selectedItemTag) |
| : base(context, searchPatterns, viewPaths, uploadPaths, deletePaths, selectedUrl, selectedItemTag) |
| { |
| } |
| public override string StoreFile(UploadedFile file, string path, string name, params string[] arguments) |
| { |
| string fileName = base.StoreFile(file, path, name, arguments); |
| //create thumbnail here |
| // |
| return fileName; |
| } |
| } |
Lini
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
Scott
