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

2 posts, 0 answers
  1. Felipe Casanova
    Felipe Casanova avatar
    56 posts
    Member since:
    Feb 2010

    Posted 19 Aug 2011 Link to this post

    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;
                }
                  
            }
        }
    }

  2. Dobromir
    Admin
    Dobromir avatar
    1633 posts

    Posted 23 Aug 2011 Link to this post

    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 >>

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