This is a migrated thread and some comments may be shown as answers.

File Manager with CustomFileSystemProvider

4 Answers 211 Views
FileExplorer
This is a migrated thread and some comments may be shown as answers.
Anthony
Top achievements
Rank 1
Anthony asked on 31 Jan 2013, 05:22 PM

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.

4 Answers, 1 is accepted

Sort by
0
Vessy
Telerik team
answered on 01 Feb 2013, 01:24 PM
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.
0
Anthony
Top achievements
Rank 1
answered on 01 Feb 2013, 02:46 PM

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?

0
Anthony
Top achievements
Rank 1
answered on 04 Feb 2013, 10:13 PM
Hi,

Any thoughts on how we can do this?

Thanks
0
Vessy
Telerik team
answered on 05 Feb 2013, 04:56 PM
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.
Tags
FileExplorer
Asked by
Anthony
Top achievements
Rank 1
Answers by
Vessy
Telerik team
Anthony
Top achievements
Rank 1
Share this question
or