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

Pass extra fields from Upload dialog to custom content provider StoreFile() method

1 Answer 130 Views
FileExplorer
This is a migrated thread and some comments may be shown as answers.
Felipe Casanova
Top achievements
Rank 1
Felipe Casanova asked on 19 Aug 2011, 10:14 AM
How do I pass the retrieved extra values from my Upload dialog to my Custom content provider's StoreFile method? I see there is a string[] arguments parameter but how do I set this value?
protected void RadFileExplorer1_ItemCommand(object sender, Telerik.Web.UI.RadFileExplorerEventArgs e)
{
    if (e.Command == "UploadFile")
    {
        Telerik.Web.UI.RadFileExplorer explorer = sender as Telerik.Web.UI.RadFileExplorer;
        Telerik.Web.UI.RadUpload upload = explorer.Upload;
  
        //e.Path holds the file path
        string name = e.Path.Split(new char[] { '/' }).Last(); // get the filename including extension ;
  
        foreach (Telerik.Web.UI.UploadedFile uploadedFile in upload.UploadedFiles)
        {
            if (name.Equals(uploadedFile.GetName()))
            {
                string fileName = uploadedFile.GetName();
                string imageSize = uploadedFile.GetFieldValue("imageSize");
  
                // would like to pass imageSize to StoreFile method...
                  
                break;
            }
              
        }
    }
}

1 Answer, 1 is accepted

Sort by
0
Dobromir
Telerik team
answered on 23 Aug 2011, 09:51 AM
Hi Matt,

I have already answered to your question in this forum thread. For convenience I will paste my answer here as well.

In order to pass the arguments to the StoreFile() method you need to cancel the default execution of ItemCommand event and manually call the method, e.g.:
FileSystemContentProvider _contentProvider = null;
private FileSystemContentProvider ContentProvider
{
    get
    {
        if (object.Equals(this._contentProvider, null))
        {
            this._contentProvider = new FileSystemContentProvider(this.Context,
                                            RadFileExplorer1.Configuration.SearchPatterns,
                                            RadFileExplorer1.Configuration.ViewPaths,
                                            RadFileExplorer1.Configuration.UploadPaths,
                                            RadFileExplorer1.Configuration.DeletePaths,
                                            string.Empty,
                                            string.Empty);
        }
        return this._contentProvider;
    }
}
  
  
void RadFileExplorer1_ItemCommand(object sender, RadFileExplorerEventArgs e)
{
    if (e.Command == "UploadFile")
    {
        //.........
        foreach (UploadedFile uploadedFile in upload.UploadedFiles)
        {
            if (name.Equals(uploadedFile.GetName()))
            {
                string[] arguments = new string[] { "argument1", "argument2" };
                explorer.InitialPath = this.ContentProvider.StoreFile(uploadedFile, explorer.CurrentFolder, uploadedFile.GetName(), arguments);
  
                //.......
            }
        }
    }
}


Greetings,
Dobromir
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

Tags
FileExplorer
Asked by
Felipe Casanova
Top achievements
Rank 1
Answers by
Dobromir
Telerik team
Share this question
or