This is a migrated thread and some comments may be shown as answers.
RadEditor Imagemanager controls disabled
10 Answers 78 Views
This is a migrated thread and some comments may be shown as answers.
Adam
Top achievements
Rank 1
Adam asked on 05 May 2014, 06:06 AM
I realise there are several threads on this subject and I have read every one I can find. I have tried all of the suggested solutions, but to no avail.
I've tried teh following solutions:

 Cannot get Upload/Delete to show
 Troubleshooting.

http://www.telerik.com/forums/radeditor-image-manager-upload-button-and-others-disabled---windows-authentication
http://stackoverflow.com/questions/12199021/rad-editor-telerik-control-image-manager-and-asp-net-button-issues-not-working
http://www.telerik.com/forums/radeditor-image-manager-buttons-disabled


My ImageManager WAS working until I updated to 2014 Q1. Since then, all of the tools in the ImageManager toolbar are disabled in all the environments I deploy to.
I get no permissions errors or any indication as to why the user can't upload.

I've checked and double checked the handlers in the web config.
I've tried removing and re-adding the Telerik references
I've tried removing and re-adding the RadEditor control with default settings.
I've tried checking the Smart Menu to make sure that the handler config is right.
I've set my Upload/Delete/View folder paths programmatically and declaratively.
I've tried setting the location in the webconfig

Here's my code

<system.webServer>
  <modules runAllManagedModulesForAllRequests="true">
     
     
    <remove name="RadUploadModule" />
    <remove name="RadCompression" /><add name="UrlRewriter" type="Intelligencia.UrlRewriter.RewriterHttpModule, Intelligencia.UrlRewriter" />
    <add name="ExceptionlessModule" type="Exceptionless.Web.ExceptionlessModule, Exceptionless.Web" />
    <add name="RadUploadModule" type="Telerik.Web.UI.RadUploadHttpModule" preCondition="integratedMode" />
    <add name="RadCompression" type="Telerik.Web.UI.RadCompression" preCondition="integratedMode" />
  </modules>
  <validation validateIntegratedModeConfiguration="false" />
  <handlers>
     
    <remove name="ChartImage_axd" />
    <remove name="Telerik_Web_UI_SpellCheckHandler_axd" />
    <remove name="Telerik_Web_UI_DialogHandler_aspx" />
    <remove name="Telerik_RadUploadProgressHandler_ashx" />
    <remove name="Telerik_Web_UI_WebResource_axd" />
    <add name="Telerik_Web_UI_DialogHandler_aspx" path="Telerik.Web.UI.DialogHandler.aspx" type="Telerik.Web.UI.DialogHandler" verb="*" preCondition="integratedMode" />
    <add name="Telerik_Web_UI_WebResource_axd" path="Telerik.Web.UI.WebResource.axd" type="Telerik.Web.UI.WebResource" verb="*" preCondition="integratedMode" />
    <add name="Telerik_Web_UI_SpellCheckHandler_axd" path="Telerik.Web.UI.SpellCheckHandler.axd" type="Telerik.Web.UI.SpellCheckHandler" verb="*" preCondition="integratedMode" />
    <add name="ChartImage_axd" path="ChartImage.axd" type="Telerik.Web.UI.ChartHttpHandler" verb="*" preCondition="integratedMode" />
    <add name="Telerik_RadUploadProgressHandler_ashx" path="Telerik.RadUploadProgressHandler.ashx" type="Telerik.Web.UI.RadUploadProgressHandler" verb="*" preCondition="integratedMode" />
  </handlers>
</system.webServer>


<telerik:RadEditor ID="BodyRadEditor" runat="server" Width="100%"  AllowScripts="True">
        <ContextMenus>
            <telerik:EditorContextMenu TagName="IMG">
                <telerik:EditorTool Name="SetImageProperties" />
            </telerik:EditorContextMenu>
            <telerik:EditorContextMenu TagName="TABLE">
                <telerik:EditorTool Name="ToggleTableBorder" />
                <telerik:EditorTool Name="SetTableProperties" />
                <telerik:EditorTool Name="DeleteTable" />
            </telerik:EditorContextMenu>
            <telerik:EditorContextMenu TagName="TD">
                <telerik:EditorTool Name="InsertRowAbove" />
                <telerik:EditorTool Name="InsertRowBelow" />
                <telerik:EditorTool Name="DeleteRow" />
                <telerik:EditorTool Name="InsertColumnLeft" />
                <telerik:EditorTool Name="InsertColumnRight" />
                <telerik:EditorTool Name="MergeColumns" />
                <telerik:EditorTool Name="MergeRows" />
                <telerik:EditorTool Name="SplitCell" />
                <telerik:EditorTool Name="DeleteCell" />
                <telerik:EditorTool Name="SetCellProperties" />
            </telerik:EditorContextMenu>
                    <telerik:EditorContextMenu TagName="BODY">
                    <telerik:EditorTool Name="PasteFromWord" />
                    <telerik:EditorTool Name="PastePlainText" />
                    <telerik:EditorTool Name="PasteAsHtml" />
                </telerik:EditorContextMenu>
        </ContextMenus>
 
    <Tools>
        <telerik:EditorToolGroup Tag="MainToolbar">
            <telerik:EditorSplitButton Name="Undo">
            </telerik:EditorSplitButton>
            <telerik:EditorSplitButton Name="Redo">
            </telerik:EditorSplitButton>
            <telerik:EditorSeparator />
            <telerik:EditorTool Name="Print" ShortCut="CTRL+P / CMD+P" />
            <telerik:EditorTool Name="AjaxSpellCheck" />
            <telerik:EditorTool Name="FindAndReplace" ShortCut="CTRL+F / CMD+F" />
            <telerik:EditorTool Name="SelectAll" ShortCut="CTRL+A / CMD+A" />
            <telerik:EditorTool Name="Cut" ShortCut="CTRL+X / CMD+X" />
            <telerik:EditorTool Name="Copy" ShortCut="CTRL+C / CMD+C" />
            <telerik:EditorTool Name="Paste" ShortCut="CTRL+V / CMD+V" />
            <telerik:EditorToolStrip Name="PasteStrip">
            </telerik:EditorToolStrip>
        </telerik:EditorToolGroup>
        <telerik:EditorToolGroup Tag="InsertToolbar">
            <telerik:EditorTool Name="ImageManager" ShortCut="CTRL+G / CMD+G" />
            <telerik:EditorSeparator />
            <telerik:EditorTool Name="LinkManager" />
            <telerik:EditorTool Name="InsertLink" />
        </telerik:EditorToolGroup>
        <telerik:EditorToolGroup Tag="DropdownToolbar">
            <telerik:EditorSplitButton Name="InsertSymbol">
            </telerik:EditorSplitButton>
            <telerik:EditorToolStrip Name="InsertTable">
            </telerik:EditorToolStrip>
                <telerik:EditorTool Name="ToggleTableBorder" />
        </telerik:EditorToolGroup>
        <telerik:EditorToolGroup>
            <telerik:EditorTool Name="JustifyLeft" />
            <telerik:EditorTool Name="JustifyCenter" />
            <telerik:EditorTool Name="JustifyRight" />
            <telerik:EditorTool Name="JustifyFull" />
            <telerik:EditorTool Name="JustifyNone" />
            <telerik:EditorSeparator />
            <telerik:EditorTool Name="Indent" />
            <telerik:EditorTool Name="Outdent" />
            <telerik:EditorSeparator />
            <telerik:EditorTool Name="InsertOrderedList" />
            <telerik:EditorTool Name="InsertUnorderedList" />
        </telerik:EditorToolGroup>
        <telerik:EditorToolGroup>
            <telerik:EditorTool Name="FormatSets" />
            <telerik:EditorTool Name="Bold" ShortCut="CTRL+B / CMD+B" />
            <telerik:EditorTool Name="Italic" ShortCut="CTRL+I / CMD+I" />
            <telerik:EditorTool Name="Underline" ShortCut="CTRL+U / CMD+U" />
            <telerik:EditorTool Name="StrikeThrough" />
        </telerik:EditorToolGroup>
    </Tools>
    <Content>
</Content>
 
    <ImageManager EnableAsyncUpload="true" AllowFileExtensionRename="False" AllowMultipleSelection="True" MaxUploadFileSize="2048000" DeletePaths="~/Uploads" UploadPaths="~/Uploads" ViewPaths="~/Uploads"></ImageManager>
    <TrackChangesSettings CanAcceptTrackChanges="False"></TrackChangesSettings>
</telerik:RadEditor>

        protected virtual void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                ArticleMultiView.SetActiveView(ArticleFormView);
 
                if (!Directory.Exists(Server.MapPath(@"~/Uploads/" + user.Username)))
                    Directory.CreateDirectory(Server.MapPath(@"~/Uploads/" + user.Username));
 
                
                string[] path = new string[] { @"~/Uploads/" + user.Username + "/" };
 
                BodyRadEditor.ImageManager.UploadPaths = path;
                BodyRadEditor.ImageManager.ViewPaths = path;
                BodyRadEditor.ImageManager.DeletePaths = path;
...
...
...
               }
         }

10 Answers, 1 is accepted

Sort by
0
Rumen
Telerik team
answered on 06 May 2014, 09:14 AM
Hello,

I just replied to your support ticket on the subject.

For reference I am pasting below my answer:

It is strange to experience this problem with the purchased version, but not with the trial one, because the sole differences between both versions is the trial error message. Your code looks also fine and should work.

Can you please make a simple test by replacing manually the registered Telerik.Web.UI.dll with the trial one? Does the problem still persist?

Another test is to remove the code behind code for setting the Image manager paths

string[] path = newstring[] { @"~/Uploads/"+ user.Username + "/"};

BodyRadEditor.ImageManager.UploadPaths = path;

BodyRadEditor.ImageManager.ViewPaths = path;

BodyRadEditor.ImageManager.DeletePaths = path;


and keeping the configuration in the aspx file

DeletePaths="~/Uploads"UploadPaths="~/Uploads"ViewPaths="~/Uploads"


and ensuring that the Uploads folder is available in the root of your web application or web site.

Just for test give full permissions to the everyone user for the Uploads folder.

If this does not work again, try to remove the configuration properties one by one until the the Upload functionality starts to work. You can also create a simple test project until you verify that the Image Manager works as expected. After that compare the settings of both apps.



Kind r
egards,
Rumen
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Sudam
Top achievements
Rank 1
answered on 27 Apr 2020, 10:02 AM

Hi Rumen, I am too facing same issue, the upload button is disabled. I tried https://docs.telerik.com/devtools/aspnet-ajax/controls/fileexplorer/troubleshooting/common-issues, FullPermissionsTest passes successfully.

Below code I am using for open dialog

 

DialogOpener opener = this.FindControl(this.ClientID + "dialogOpener") as DialogOpener;

InitFileManagerDialog(opener.DialogDefinitions["ImageManager"], FileManagerService.ImageRoot.Replace("/", String.Empty),
                        int.Parse(ConfigurationManager.AppSettings["FileManagerMaxImageSizeKB"]),
                        ConfigurationManager.AppSettings["FileManagerImageExtensions"].Split(",".ToCharArray()), opener, false);

 

 

 

public static void InitFileManagerDialog(DialogDefinition dialog, String path, int maxSize, String[] searchPatterns, RadDialogOpener opener, bool returnName, bool common = false)
        {
            dialog.Parameters["FileBrowserContentProviderTypeName"] = typeof(WishlistFileBrowserContentProvider).AssemblyQualifiedName;
            dialog.Parameters["ViewPaths"] = new[] { path };
            dialog.Parameters["UploadPaths"] = new[] { path };
            dialog.Parameters["MaxUploadFileSize"] = maxSize / 1000 * 1024 * 1024;

            if ((searchPatterns != null) && (searchPatterns.Length > 0))
                dialog.Parameters["SearchPatterns"] = searchPatterns;

            //add the query strings needed for SiteResolver to work
            opener.AdditionalQueryString = String.Format("&CurrentSiteUrl={0}&redirect=true&ReturnName={1}&common={2}", HttpUtility.UrlEncode(new Uri(A2Site.CurrentSite.BaseURL).AbsolutePath), returnName, common);
            opener.HandlerUrl = "~/Telerik.Web.UI.DialogHandler.aspx";
        }

0
Rumen
Telerik team
answered on 29 Apr 2020, 01:26 PM

Hi Sudam,

Do you experience this issue, if you remove/detach your FileBrowserContentProviderTypeName custom provider? 

What happens if you drop a standard RadEditor or RadFileExplorer on the same page and configure their ViewPath and UploadPath properties to point to ~/ or a folder under the root of the app?

Regards,
Rumen
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
0
Sudam
Top achievements
Rank 1
answered on 30 Apr 2020, 12:56 PM

Hi Rumen, I f I remove custom FileBrowserContentProviderTypeName  I am getting below error message

 

The relative virtual path 'imageroot' is not allowed here.

 

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ArgumentException: The relative virtual path 'imageroot' is not allowed here.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:

[ArgumentException: The relative virtual path 'imageroot' is not allowed here.] System.Web.VirtualPath.Create(String virtualPath, VirtualPathOptions options) +10039069 Telerik.Web.UI.Widgets.FileSystemContentProvider.ResolveRootDirectoryAsTree(String path) +56 Telerik.Web.UI.RadFileExplorer.BindExplorer() +128 Telerik.Web.UI.RadFileExplorer.<ControlPreRender>b__3() +5 Telerik.Web.UI.RadFileExplorer.BindTreeView(Action bindExplorer) +240 Telerik.Web.UI.RadFileExplorer.ControlPreRender() +533 Telerik.Web.UI.RadWebControl.OnPreRender(EventArgs e) +22 System.Web.UI.Control.PreRenderRecursiveInternal() +90 System.Web.UI.Control.PreRenderRecursiveInternal() +163 System.Web.UI.Control.PreRenderRecursiveInternal() +163 System.Web.UI.Control.PreRenderRecursiveInternal() +163 System.Web.UI.Control.PreRenderRecursiveInternal() +163 System.Web.UI.Control.PreRenderRecursiveInternal() +163 System.Web.UI.Control.PreRenderRecursiveInternal() +163 System.Web.UI.Control.PreRenderRecursiveInternal() +163 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +906

0
Rumen
Telerik team
answered on 30 Apr 2020, 01:05 PM

Hi Sudam,

Try to place ~/ tilde in front of the image path as suggested at

https://stackoverflow.com/questions/6455850/the-relative-virtual-path-is-not-allowed-here 

Regards,
Rumen
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
0
Sudam
Top achievements
Rank 1
answered on 30 Apr 2020, 01:12 PM

Hi Rumen, If I remove custom FileBrowserContentProvider and provide proper path then ImageManager is working fine. Below is code I am using for Custom FileBrowserContentProvider.

Could you tell whats wrong there?

 

using System;
using System.Collections;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Web;

using Microsoft.Practices.EnterpriseLibrary.Validation;

using Telerik.Web.UI;
using Telerik.Web.UI.Widgets;

using Wishlist.DataLayer;
using Wishlist.Services.BusinessEntity.File;
using Wishlist.Services.BusinessEntity.Site;
using Wishlist.Services.Common;
using Wishlist.Services.File;
using Wishlist.Services.Framework.Security;
using Wishlist.Services.Members;

namespace OCTWebControls
{
    /// <summary>
    /// used to provide the content to telerik document manager and image manager dialogs
    /// </summary>
    public class WishlistFileBrowserContentProvider : FileBrowserContentProvider
    {
        private const PathPermissions FullPermissions = PathPermissions.Read | PathPermissions.Delete | PathPermissions.Upload;

        public WishlistFileBrowserContentProvider(HttpContext context, string[] searchPatterns, string[] viewPaths, string[] uploadPaths, string[] deletePaths, string selectedUrl, string selectedItemTag)
            : base(context, searchPatterns, viewPaths, uploadPaths, deletePaths, selectedUrl, selectedItemTag)
        {
            //security check in case the user just typed in a Url in an attempt to access another site
            if (MemberPrincipal.CurrentMember.CurrentProfile.CommunityGroupId != A2Site.CurrentSite.CommunityGroupId)
            {
                throw new UnauthorizedAccessException();
            }

            //application-wide file management is only available for department pages
            if (IsCommon)
            {
                PermissionService.AuthorizeUser(PermissionCode.CanManageCatalogueApplication);
            }
        }

        /// <summary>
        /// when return id mode is switched on, the file browser returns only a file id
        /// </summary>
        private bool AddFileNameToReturnValue
        {
            get { return !StringFunctions.IsNullOrTrimmedEmpty(this.Context.Request.QueryString["ReturnName"]); }
        }

        public override string GetFileName(string url)
        {
            return FileManagerService.GetName(url);
        }

        public override string GetPath(string url)
        {
            return FileManagerService.GetDirectoryPath(ExtractPath(RemoveProtocolNameAndServerName(url)));
        }

        public override DirectoryItem ResolveRootDirectoryAsTree(string path)
        {
            A2Folder folder = FileManagerService.GetFolderByPath(StringFunctions.EndWithSlash(path), FileManagerSiteId);

            FileItem[] fileItems = this.GetChildFileItems(folder);

            DirectoryItem[] directoryItems = this.GetChildDirectoryItems(folder.GetFolders());

            string name = FileManagerService.GetName(path);
            string location = FileManagerService.GetDirectoryPath(path);

            DirectoryItem directoryItem = new DirectoryItem(name, location, String.Empty, String.Empty, FullPermissions, fileItems, directoryItems);

            return directoryItem;
        }

        public override DirectoryItem[] ResolveRootDirectoryAsList(string path)
        {
            A2Folder folder = FileManagerService.GetFolderByPath(StringFunctions.EndWithSlash(path), FileManagerSiteId);
            PathPermissions folderPermissions = FullPermissions;

            if (folder.IsParent)
            {
                //can't delete the root
                folderPermissions ^= PathPermissions.Delete;
            }

            DirectoryItem[] directoryItems = this.GetChildDirectoryItems(folder.GetFolders());
            FileItem[] fileItems = this.GetChildFileItems(folder);

            string name = FileManagerService.GetName(path);
            string location = FileManagerService.GetDirectoryPath(path);

            DirectoryItem item = new DirectoryItem(name, location, String.Empty, String.Empty, folderPermissions, fileItems, directoryItems);

            ArrayList list = new ArrayList();
            list.Add(item);
            list.AddRange(directoryItems);

            return directoryItems;
        }

        public override DirectoryItem ResolveDirectory(string path)
        {
            DirectoryItem[] directories = null;

            PathPermissions folderPermissions = FullPermissions;

            A2Folder folder = FileManagerService.GetFolderByPath(StringFunctions.EndWithSlash(FileManagerService.GetDirectoryPath(path)), FileManagerSiteId);

            //if (this.DisplayMode == FileBrowserDisplayMode.List)
            //{
            //    directories = new DirectoryItem[0];
            //}
            //else
            //{
                if (folder != null)
                {
                    directories = this.GetChildDirectoryItems(folder.GetFolders());

                    if (folder.IsParent)
                    {
                        //can't delete the root
                        folderPermissions = FullPermissions ^ PathPermissions.Delete;
                    }
                }
            //}

            FileItem[] fileItems = this.GetChildFileItems(folder);

            string name = FileManagerService.GetName(path);
            string location = StringFunctions.EndWithSlash(FileManagerService.GetDirectoryPath(path));

            DirectoryItem directoryItem = new DirectoryItem(name, location, String.Empty, String.Empty, folderPermissions, fileItems, directories);

            return directoryItem;
        }

        public override Stream GetFile(string url)
        {
            IFileManagerService fileManager = new FileManagerServiceDefault();

            A2File a2File = fileManager.GetFileByFilePath(url, FileManagerSiteId);

            return a2File == null ? null : fileManager.GetFileStream(fileManager.GetRelativePath(a2File));
        }

        //does not seem to be used
        public override string StoreBitmap(Bitmap bitmap, string url, ImageFormat format)
        {
            return String.Empty;
        }

        public override string StoreFile(UploadedFile file, string path, string name, params string[] arguments)
        {
            if (file.ContentType.Equals("application/octet-stream", StringComparison.OrdinalIgnoreCase))
            {
                ApplicationException ex = new ApplicationException("File MIME Type not allowed.");
                ex.Data["path"] = path;
                ex.Data["name"] = name;
                throw ex;
            }

            int fileLength = (int)file.InputStream.Length;
            byte[] content = new byte[fileLength];
            file.InputStream.Read(content, 0, fileLength);

            A2Folder folder = FileManagerService.GetFolderByPath(path, FileManagerSiteId);

            A2File f = new A2File();

            A2File existingFile = folder.GetFiles().Find(item => String.Equals(item.Name, name, StringComparison.OrdinalIgnoreCase));

            if (existingFile != null)
            {
                f = existingFile.Clone();
            }

            //an update changes the contents and last updated info only
            f.Upload = this.Context.Request.Files[0];

            if (f.IsNew)
            {
                string filePath = CombinePath(path, name);
                string key = FileManagerService.GenerateFileKey(filePath, FileManagerSiteId.GetValueOrDefault());
                f.Url = key;
                //ensure that the file has a unique name
                f.FolderId = folder.Id;
                f.Name = name;
                f.RelativeFilePath = filePath.TrimStart(new[] { '\\' });
                f.FolderPath = path;
                f.SiteId = FileManagerSiteId;
            }

            if (Validation.Validate(f).IsValid)
            {
                f.Save(new ValidationResults());
            }
            else
            {
                //if you read the source code of FileUploader.ascx in the RadEditor source, it looks like the only 
                //way to give feedback to the upload dialog that StoreFile did not work is to throw an UnauthorizedAccessException.
                //Therefore I am throwing the exception and changing the localized string in the Xml to say something appropriate.
                throw new UnauthorizedAccessException();
            }

            return String.Empty;
        }

        public override string DeleteFile(string path)
        {
            A2File file = FileManagerService.GetFileByFilePath(path, FileManagerSiteId);
            file.MarkToDelete();
            file.Save(new ValidationResults());

            return String.Empty;
        }

        public override string DeleteDirectory(string path)
        {
            A2Folder folder = FileManagerService.GetFolderByPath(path, FileManagerSiteId).Clone();
            folder.MarkToDelete();
            folder.Save(new ValidationResults());

            return String.Empty;
        }

        public override string CreateDirectory(string path, string name)
        {
            A2Folder folder = new A2Folder();

            folder.Name = name;
            folder.Path = StringFunctions.EndWithSlash(path) + StringFunctions.EndWithSlash(name);
            folder.ParentId = FileManagerService.GetFolderByPath(path, FileManagerSiteId).Id;
            folder.SiteId = FileManagerSiteId;

            if (Validation.Validate(folder).IsValid)
            {
                folder.Save(new ValidationResults());
                this.SelectedUrl = folder.Path;
            }
            else
            {
                //maybe this is ugly but there doesn't seem to be a nice way to ask for the first item in
                //the ValidationResults collection because it doesn't have an indexer
                foreach (ValidationResult result in folder.ValidationResults)
                {
                    return result.Message;
                }
            }

            return String.Empty;
        }

        public override bool CanCreateDirectory
        {
            get { return true; }
        }

        #region Helpers

        /// <summary>
        /// map file business entity to telerik file item
        /// </summary>
        /// <returns></returns>
        private FileItem[] GetChildFileItems(A2Folder folder)
        {
            if (folder != null)
            {
                EntityCollection<A2File> files = folder.GetFiles();

                ArrayList fileItems = new ArrayList();

                foreach (A2File file in files)
                {
                    if (this.IsExtensionAllowed(file.Extension))
                    {
                        FileItem newItem = new FileItem(file.Name, file.Extension, file.Size, String.Empty, this.GetItemUrl(file, false), CombinePath(folder.Path, file.Name), FullPermissions);

                        //this will set the tooltip which via some javascript can be used as the link text when a document is selected
                        newItem.Attributes.Add(file.Name, file.Name);

                        fileItems.Add(newItem);
                    }
                }

                return (FileItem[])fileItems.ToArray(typeof(FileItem));
            }

            return new FileItem[0];
        }

        /// <summary>
        /// map folder business entity to telerik directory items. don't add any sub-folders since we haven't browsed to them yet
        /// </summary>
        /// <returns></returns>
        private DirectoryItem[] GetChildDirectoryItems(EntityCollection<A2Folder> folders)
        {
            ArrayList folderItems = new ArrayList();

            if (folders != null && folders.Count > 0)
            {
                foreach (A2Folder folder in folders)
                {
                    DirectoryItem[] directoryItems = new DirectoryItem[0];
                    FileItem[] fileItems = new FileItem[0];

                    EntityCollection<A2Folder> subFolders = folder.GetFolders();
                    EntityCollection<A2File> subFiles = folder.GetFiles();

                    if (subFolders != null && subFolders.Count > 0)
                    {
                        directoryItems = this.GetChildDirectoryItems(folder.GetFolders());
                    }

                    if ((subFiles != null && subFiles.Count > 0))
                    {
                        fileItems = this.GetChildFileItems(folder);
                    }

                    DirectoryItem item = new DirectoryItem(folder.Name, String.Empty, folder.Path, folder.Path, FullPermissions, fileItems, directoryItems);

                    folderItems.Add(item);
                }
            }

            return (DirectoryItem[])folderItems.ToArray(typeof(DirectoryItem));
        }

        /// <summary>
        /// construct a url for the file that goes through the handler
        /// </summary>
        /// <param name="a2File"></param>
        /// <param name="cacheImg"></param>
        /// <returns></returns>
        private string GetItemUrl(A2File a2File, bool cacheImg)
        {
            return FileManagerService.GetItemUrl(a2File, this.AddFileNameToReturnValue, FileManagerSiteId, cacheImg);
        }

        /// <summary>
        /// get the path from the url
        /// </summary>
        /// <param name="itemUrl"></param>
        /// <returns></returns>
        private static string ExtractPath(string itemUrl)
        {
            return itemUrl ?? String.Empty;
        }

        /// <summary>
        /// filter on extension
        /// </summary>
        /// <param name="extension"></param>
        /// <returns></returns>
        private bool IsExtensionAllowed(string extension)
        {
            return Array.IndexOf(this.SearchPatterns, "*.*") >= 0 || Array.IndexOf(this.SearchPatterns, "*" + extension.ToLower()) >= 0;
        }

        /// <summary>
        /// combine the path in a way that makes sense for the file browser
        /// </summary>
        /// <param name="path1"></param>
        /// <param name="path2"></param>
        /// <returns></returns>
        private static string CombinePath(string path1, string path2)
        {
            if (path1.EndsWith("/"))
            {
                return string.Format("{0}{1}", path1, path2);
            }

            if (path1.EndsWith("\\"))
            {
                path1 = path1.Substring(0, path1.Length - 1);
            }

            return string.Format("{0}/{1}", path1, path2);
        }

        /// <summary>
        /// gets the site id we want to pass when calling the file manager service
        /// </summary>
        /// <remarks>the effective site id is null when the "common" query string is set to true</remarks>
        private static int? FileManagerSiteId
        {
            get { return IsCommon ? default(int?) : A2Site.CurrentSite.Id; }
        }

        private static bool IsCommon
        {
            get { return Utils.GetQueryString<bool>(HttpContext.Current.Request, "common"); }
        }

        #endregion
    }
}

0
Rumen
Telerik team
answered on 05 May 2020, 10:58 AM

Hi Sudam,

Thank you for the provided code.

I examined the Custom Content Provider and noticed that there are several methods needed by RadEditor/FileExplorer, which are missing in the used custom content provider. Please, note, that in order for the control to be able to function properly you have to override all methods listed here. The methods missing implementation in your provider are:

        CheckDeletePermissions(string folderPath)
CheckReadPermissions(string folderPath)
        CheckWritePermissions(string folderPath)
        MoveFile(string path, string newPath)
        MoveDirectory(string path, string newPath)
        CopyFile(string path, string newPath)
        CopyDirectory(string path, string newPath)

Along with the implementation of the missing methods above, the CheckReadPermissions, CheckWritePermissions and CheckDeletePermissions permissions methods should return true so that the Upload button gets enabled.

 

Regards,
Rumen
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
0
Sudam
Top achievements
Rank 1
answered on 05 May 2020, 01:01 PM

Thanks Rumen for your reply. I have implemented them as below.

Still not working as folderPath parameter is getting empty string for checkPermissions methods

public override bool CheckDeletePermissions(
            string folderPath)
        {
            return base.CheckDeletePermissions(folderPath);
        }

        public override bool CheckWritePermissions(
                    string folderPath)
        {
            return base.CheckWritePermissions(folderPath);
        }

        public override bool CheckReadPermissions(
                    string folderPath)
        {
            return base.CheckReadPermissions(folderPath);
        }

        public override string MoveFile(string path, string newPath)
        {
            return base.MoveFile(path, newPath);
        }

        public override string CopyDirectory(string path, string newPath)
        {
            return base.CopyDirectory(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);
        }

Thanks,

Sudam

0
Sudam
Top achievements
Rank 1
answered on 05 May 2020, 01:03 PM
Hi Rumen, I have implemented them and calling base methods. but issue is I am getting empty folderPath parameter for checkPermission methods
0
Rumen
Telerik team
answered on 05 May 2020, 01:40 PM

Could it be that the second param of the public static void InitFileManagerDialog function is incorrect or an empty string- > FileManagerService.ImageRoot.Replace("/", String.Empty) ?

My advice is to examine the code of the following three resources which offer properly working FileBrowserContentProvider and to compare their implementation with yours:

If you need further assistance, please isolate the problem in a simple runnable project and send it for examination via a support ticket.

p.s. I noticed that the URL from my previous post wasn't working so I updated it to https://docs.telerik.com/devtools/aspnet-ajax/controls/fileexplorer/server-side-programming/use-custom-filebrowsercontentprovider.

Best Regards,
Rumen
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
Asked by
Adam
Top achievements
Rank 1
Answers by
Rumen
Telerik team
Sudam
Top achievements
Rank 1
Share this question
or