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

Set File Attribute during Upload using FileExplorer

4 Answers 114 Views
FileExplorer
This is a migrated thread and some comments may be shown as answers.
Leo Baumer
Top achievements
Rank 1
Leo Baumer asked on 13 Aug 2010, 05:47 PM
Hello,

I would like some direction or code samples in how to set file attributes during file uploads using FileExplorer. I was able to display the file Created Date and Owner Name attributes in the grid using the examples on this site, however, my requirement is to display the name of the user who uploaded the file (the Owner Name is always BUILTIN/Administrators).

Regards,
Leo

4 Answers, 1 is accepted

Sort by
0
Fiko
Telerik team
answered on 18 Aug 2010, 04:13 PM
Hi Leo,

I have already answered your support ticket. For convenience I have pasted a part of my answer here:
"In general I recommend you to use this method:
  • Inherit the Telerik Telerik.Web.UI.Widgets.FileSystemContentProvider class (or build a completely new provider) and override its StoreFile method.
  • Set the new content provider to the RadFileExplorer:
    RadFileExplorer1.Configuration.ContentProviderTypeName = typeof(CustomProvider).AssemblyQualifiedName;
  • Implement the StoreFile method in order to save the file (this method should return the virtual path to the stored file).
  • Inside the StoreFile method, get the reference to the page object, which hosts the RadFileExplorer control using this approach.
  • Get the user name of the logged user:
    string userName = _page.User.Identity.Name
  • Please note that you need to implement a custom logic here which will associate the saved file with the user which uploads the file. This can be done in many ways (for example, storing the files in a database and adding a column, which contains the username)
"

Greetings,
Fiko
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Aaron C
Top achievements
Rank 1
answered on 18 Aug 2010, 09:34 PM
Hi Fiko,

I am trying to do something similar, and I have my Custom provider built, and I have an override method for StoreFile.  However when I debug StoreFile does not get called when I upload a file, GetFile is called first.  I must be misunderstanding something, because the file has not yet been uploaded and there is no way to get it.  Your response to Leo was very helpful, could you please explain what needs to be done in general to upload a file using a custom provider? 
0
Fiko
Telerik team
answered on 24 Aug 2010, 10:59 AM
Hi Aaron,

The RadFileExplorer control calls the GetFile method in order to determine whether a file exists or not. If the  method returns null (Nothing in VB.NET), then the StoreFile method will be called. Please note that store method will be called even when the GetFile returns an object (not null) if the Override checkbox is checked in the upload dialog.

I hope this helps.

Regards,
Fiko
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Aaron C
Top achievements
Rank 1
answered on 24 Aug 2010, 04:36 PM
Thanks Fiko, that makes sense. 
Tags
FileExplorer
Asked by
Leo Baumer
Top achievements
Rank 1
Answers by
Fiko
Telerik team
Aaron C
Top achievements
Rank 1
Share this question
or