File Manager with CustomFileSystemProvider

5 posts, 0 answers
  1. Anthony
    Anthony avatar
    17 posts
    Member since:
    Feb 2008

    Posted 31 Jan 2013 Link to this post


    We are using the File Explorer with a CustomFileSystemProvider. When a user uploads a file, there is a method to check if the user has access to the share the file is being uploaded to. The method is called CheckWritePermissions:

    public override bool CheckWritePermissions(string virtualTargetPath)

    The method signature only provides access to the path of the folder. However, we need to also access the filename that is being uploaded as well, to do an additional check to see if the file already exists. At present, there doesn't seem to be any way to do this.

    Does anyone know of a way to modify the CustomFileSystemProvider to access the filename when a user uploads documents to a share? Since users can upload multiple documents at a time, the method should show the current filename that is being processed as the files are uploaded.
  2. Vessy
    Admin
    Vessy avatar
    1389 posts

    Posted 01 Feb 2013 Link to this post

    Hi Anthony,

    To achieve the desired scenario you have to override the StoreFIle() method instead of CheckWritePermissions() one (which is called in many other situations). The arguments which the StoreFIle() method receives includes as the name of the file, as the path you want to upload it too- more detailed information is available here.
    public override string StoreFile(Telerik.Web.UI.UploadedFile file, string path, string name, params string[] arguments)
    {
        throw new NotImplementedException();
    }

    Kind regards,
    Vesi
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Anthony
    Anthony avatar
    17 posts
    Member since:
    Feb 2008

    Posted 01 Feb 2013 Link to this post

    Thanks for your quick response. Just to be clear, we are already overriding the storefile method as well. We use both methods. The problem is that we want to stop the process before it actually gets to the storefile method under certain circumstances. The conditions are: 

     

    CheckWritePermissions

    • If the user doesn't have access to the network share folder, return false
    • If the user has previously uploaded the same file to the share folder, return false

    Returning false in the CheckWritePermissions method causes the FileExplorer to display a message that the user doesn't have access to upload the file(s) being uploaded. This is the result we want. 

    Once the process gets to the StoreFile method, it doesn't seem to be able to return information that indicates the user doesn't have access to upload the file, so this won't work for us.

    Is there any way to get the file name when CheckWritePermissions is called?

  5. Anthony
    Anthony avatar
    17 posts
    Member since:
    Feb 2008

    Posted 04 Feb 2013 Link to this post

    Hi,

    Any thoughts on how we can do this?

    Thanks
  6. Vessy
    Admin
    Vessy avatar
    1389 posts

    Posted 05 Feb 2013 Link to this post

    Hi Anthony,

    I am afraid to say that there is now way to take information about the existance of a file in the CheckWritePermissions() method - it is designed to check only whether the folder/file has the needed permissions. There are two possible places where you could take the name of the uploaded file:
     - In the override of StoreFile() method (that you already have overridden in your project)
     - in the handler of the RadFileExplorer's ItemCommand Server-event:
    protected void RadFileExplorer1_ItemCommand(object sender, RadFileExplorerEventArgs e)
    {
        if (e.Command == "UploadFile")
        {
            string currentFile = e.Path.ToString().Substring(e.Path.ToString().LastIndexOf("/") + 1);
        }
    }

    Additionally, if it would be of any help, I would mention that the ItemCommand's handler is executed before the StoreFile() method is called.

    Kind regards,
    Vesi
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017