DocumentManager off UNC path

10 posts, 0 answers
  1. Andrew
    Andrew avatar
    14 posts
    Member since:
    Aug 2014

    Posted 10 Oct 2014 Link to this post

    Hi Telerik community!

    I'm a newbie working on a legacy Web Forms application. We are using Telerik:RadEditor to handle some remote file uploads. The problem is we have moved the storage of these files from a relative path on the webserver to a off-web-root storage path using a UNC path.

    Our prior methodology used this call to set the DocumentManager paths

                    string[] viewReadmeDocuments = new string[] { "~/Store/" + drpProducts.SelectedItem.Text + "/ReadmeFiles" };

                    The locals debug output would be  "~/Store/My Product/ReadmeFiles".

    When I try to update the path to use a UNC path, I get nothing.

                    string storepath = "\\\\\\\\mystorageserver\\\\share";
                    string[] deleteReadmeDocument = new string[] { storePath + "\\" + drpProducts.SelectedItem.Text + "\\ReadmeFiles" };

                     The locals debug output shows the proper path: "\\\\\\\\mystorageserver\\\\share\\My Product\\ReadmeFiles;

    I am using version 2013.2.717.40 of Telerik.Web.UI.

    Any help would be appreciated. Thank you.



  2. Vessy
    Admin
    Vessy avatar
    1380 posts

    Posted 13 Oct 2014 Link to this post

    Hello Andrew,

    By design RadfileExplorer (the control used for managing files and folders in the RadEditor's dialog managers) can work only with virtual paths to files and folders placed inside the application's root directory. In order to make it work with UNC paths you will need to implement a custom FileBrowserContentProvider in the way described in this help article.

    You can follow the instructions in the article above and build your own custom provider, or to use th one implemented and provided by us here:
    Use RadFileExplorer with physical and shared folder's paths

    Regards,
    Vessy
    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.

     
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Andrew
    Andrew avatar
    14 posts
    Member since:
    Aug 2014

    Posted 27 Oct 2014 Link to this post

    here. I am trying to subclass the FileSystemContentProvider, but this line is throwing an error

    #region assign-provider_cs
    RadFileExplorer1.Configuration.ContentProviderTypeName = typeof(ExtendedFileProvider).AssemblyQualifiedName;
    #endregion

    It says that Configuration is an unknown member of Telerik.Web.UI.RadEditor. As I said before, I'm not very well versed in Telerik or C#, but I can only assume the instructions are incorrect.

    This is an example of my code. 

                    RadEditorContent.DocumentManager.ViewPaths = viewReadmeDocuments;
                    RadEditorContent.DocumentManager.UploadPaths = uploadReadmeDocuments;
                    RadEditorContent.DocumentManager.DeletePaths = deleteReadmeDocument;
                    RadEditorContent.DocumentManager.SearchPatterns = new string[] { "*.doc", "*.txt", "*.docx", "*.xls", "*.xlsx", "*.pdf", "*.htm", "*.html", "*.mht", "*.zip" };
                    RadEditorContent.DocumentManager.MaxUploadFileSize = 209715200;
                    RadEditorContent.DocumentManager.ContentProviderTypeName = typeof(Telerik.Web.UI.Widgets.FileSystemContentProvider).Name;
                    getCustomLinks(RadEditorContent);

    Here is where I tried to assign the configuration differently.

                    #region assign-provider_cs
                    RadEditorContent.Configuration.ContentProviderTypeName = typeof(ExtendedFileProvider).AssemblyQualifiedName;
                    #endregion

    Why is Configuration not a class member?




  5. Andrew
    Andrew avatar
    14 posts
    Member since:
    Aug 2014

    Posted 27 Oct 2014 in reply to Andrew Link to this post

    So. I removed Configuration from the ContentProviderTypeName and it compiled... That help link needs to be updated.

    #region assign-provider_cs
    RadEditorContent.DocumentManager.ContentProviderTypeName = typeof(ExtendedFileProvider).AssemblyQualifiedName;
     #endregion

  6. Andrew
    Andrew avatar
    14 posts
    Member since:
    Aug 2014

    Posted 29 Oct 2014 in reply to Vessy Link to this post

    This solution you gave to me ...

    http://www.telerik.com/help/aspnet-ajax/fileexplorer-custom-filebrowsercontentprovider.html

    is for the FileExplorer not the RadEditor DocumentManager control. When I try to  override the RadEditor1.DocumentManager.ContentProviderTypeName with the class listed in the solution above...

    public class ExtendedFileProvider : Telerik.Web.UI.Widgets.FileSystemContentProvider

    the override never gets implemented.

    How do I override the FileProvider for the RadEditor DocumentManager?
  7. Vessy
    Admin
    Vessy avatar
    1380 posts

    Posted 30 Oct 2014 Link to this post

    Hello Andrew,

    The control used for listing files and folders in the Document manager is FileExplorer and this is why my answer addressed this control. In order to configure directly the FileExplorer control in the way described in my previous reply you will need to enable the Editor's external dialogs and apply the changes in the FileBrowser.ascx dialog. With this approach, the assigned custom content provider will be available in all File managers dialogs (Document Manager, Image Manager, etc.).

    You can also assign a custom content provider directly to the Document manager. This approach is used in the following live demo - Custom File Dialogs Content Provider.

    Please, note that in such scenario your custom content provider has to inherit the FileBrowserContentProvider class, instead of the FileSystemContentProvider one (please, refer this help article for more details on the subject).

    For your convenience I am attaching the modified project from the linked KB, so now it includes an Editor-containing page. Please, follow the instructions from the KB in order to run the project and test it on your side.

    Regards,
    Vessy
    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.

     
  8. Andrew
    Andrew avatar
    14 posts
    Member since:
    Aug 2014

    Posted 30 Oct 2014 in reply to Vessy Link to this post

    Hello Vessy,

    I have had success overriding the DocumentManager with the FileSystemContentProvider by leveraging the example you provided. I have successfully overrided the ResolveDirectory to go to the UNC path. 

    Thank you.

    I haven't had success in trying to override the StoreFile method to handle uploads to the directory. I added this override to the existing class.

            public override string StoreFile(Telerik.Web.UI.UploadedFile file, string path, string name, params string[] arguments)
            {
                string uploadPath = this.GetPhysicalFromVirtualPath(path);

                return base.StoreFile(file, newuploadPath, name, arguments);
            }
    But it appends a "c:\MyProject" to the upload path provided by the this.GetPhysicalFromVirtualPath. So I get a resulting directory that cannot be resolved "c:\MyProject\\\\myServer\\Share\\Product\\Readme\\" No matter what I try, I cannot force the directory to use only the UNC path.

    Is this because I'm using the FileSystemContentProvider instead of the FileBrowserContentProvider?


  9. Vessy
    Admin
    Vessy avatar
    1380 posts

    Posted 04 Nov 2014 Link to this post

    Hi Andrew,

    May be I was not clear in my previous reply - please, excuse me for that.

    When you want access the content of different storage location you must implement a FileBrowsersContentProvider, defining the needed custom logic in all provider's methods. The logic of the StoreFile method is connected with the loaded folder, its permissions, etc. and cannot be overridden by itself in a scenario you want to store the uploaded file to a shared/physical path.

    Can you please elaborate on what is the reason you do not want to use the provider from the previously linked Code Library?

    Regards,
    Vessy
    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.

     
  10. Andrew
    Andrew avatar
    14 posts
    Member since:
    Aug 2014

    Posted 04 Nov 2014 in reply to Vessy Link to this post

    Vessy, first of all, thank you for responding to my posts. I was able to solve my problem, because you pointed me in the right direction, and I was able to come to a solution that worked for me because of your assistance.

    I did not want to use the example provided because it did not solve my problem. The mappings and handlers were not going to provide the UNC path mapping I need.

    I was able to use the PathHelper class and leverage the FileProvider in that solution to properly override the StoreFile ResolveDirectory and GetFiles methods to access the UNC path required. 
  11. Vessy
    Admin
    Vessy avatar
    1380 posts

    Posted 07 Nov 2014 Link to this post

    Hi Andrew,

    I am really glad the information provided by me was helpful for you and you managed to implement the desired logic in your solution. Do not hesitate to contact us should we can be of any further assistance.

    Regards,
    Vessy
    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.

     
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017