FileUploaderCustomParameters Property

Gets or sets the custom parameters for this uploader instance, to send along with the upload queue. These custom parameters can be retrieved in server-side events, for example to take an action depending on the parameters.

The key of the dictionary is of string type. The value the dictionary is of object type which means you can set any value that is JSON serializable. For values, it's recommended to use primitive types like string, bool, int etc.

Definition

Namespace: GleamTech.FileUltimate.AspNet.UI
Assembly: GleamTech.FileUltimate (in GleamTech.FileUltimate.dll) Version: 9.4.0
C#
public Dictionary<string, Object> CustomParameters { get; set; }

Property Value

DictionaryString, Object

Example

C#
//Set some custom parameters for this uploader instance, to send along with the upload queue.
var fileUploader2 = new FileUploader
{
    CustomParameters = new Dictionary<string, object>
    {
        {"MyParam1", "test"},
        {"MyParam2", true},
        {"MyParam3", 50}
    }
};

//Or set them like this:
fileUploader.CustomParameters.Add("MyParam1", "test");
fileUploader.CustomParameters.Add("MyParam2", true);
fileUploader.CustomParameters.Add("MyParam3", 50);


//In server-side events, you can examine your custom parameters via e.Queue.CustomParameters property
//and take an action depending on them.
fileUploader.Uploading += (sender, e) =>
{
    //Casting can cause problems, e.g. (int)e.Queue.CustomParameters["MyParam3"]
    //especially for int types as when JsonDeserializer is deserializing numbers from a dictionary,
    //it treats them as long (int64).
    //So use methods of Convert to avoid casting problems.

    var myParam1 = Convert.ToString(e.Queue.CustomParameters["MyParam1"]);
    var myParam2 = Convert.ToBoolean(e.Queue.CustomParameters["MyParam2"]);
    var myParam3 = Convert.ToInt32(e.Queue.CustomParameters["MyParam3"]);
};

See Also