New to Telerik UI for ASP.NET AJAXStart a free 30-day trial

Files Uploading in Custom Folder at Runtime

This article gives a brief overview how to configure the RadCloudUpload to upload files in custom folders at runtime. For example this could be a scenario you need to upload files in multiple folders for one Cloud Storage Provider or in other words these are folders that differ from the sub folder defined in the web.config.

Configure RadCloudUpload to upload files in one or multiple custom folders at Runtime

To accomplish this scenario the RadCloudUpload needs to be configured to use Custom Handler, where the default folder will be changed:

The following example is valid for a single and multiple files selections.

ASP.NET
<telerik:RadCloudUpload runat="server" ProviderType="Azure" MultipleFileSelection="Automatic" HttpHandlerUrl="~/UploadToCustomFolderHandler.ashx">
</telerik:RadCloudUpload>
C#
<%@ WebHandler Language="C#" Class="UploadToCustomFolderHandler" %>

using System;
using System.Web;

public class UploadToCustomFolderHandler : Telerik.Web.UI.CloudUploadHandler {

	public override void SetKeyName(object sender, Telerik.Web.UI.CloudUpload.SetKeyNameEventArgs e)
	{        
		var customFolder = Guid.NewGuid().ToString() + "/";
		e.KeyName = string.Format("{0}{1}_{2}", customFolder, Guid.NewGuid(), e.OriginalFileName);
	}
}

See Also