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

Custom folder name in Azure

6 Answers 98 Views
CloudUpload
This is a migrated thread and some comments may be shown as answers.
Tomasz
Top achievements
Rank 1
Tomasz asked on 14 Jan 2014, 02:17 PM

Hi,

I want to create a simple upload mechanism to Azure. I want to have a text field whre the user will enter some text and that text will became the folder name in Azure storage for that upload.



How it would be recomended to do?



6 Answers, 1 is accepted

Sort by
0
Hristo Valyavicharski
Telerik team
answered on 14 Jan 2014, 03:18 PM
Hi Tomasz,

This can be done with query string, which you pass to the custom handler. For example:

<telerik:RadCloudUpload ID="RadCloudUpload1" runat="server" ProviderType="Azure"
    MultipleFileSelection="Automatic" OnClientFileSelected="onClientFileSelected"
    HttpHandlerUrl="~/UploadToCarsFolderHandler.ashx">
</telerik:RadCloudUpload>

<script type="text/javascript">
    function onClientFileSelected(sender, args) {
        var customParam = "test";
        sender._module._handlerUrl = "/UploadToCarsFolderHandler.ashx?type=rcu&customParam=" + customParam;
    }
</script>


public override void SetKeyName(object sender, Telerik.Web.UI.CloudUpload.SetKeyNameEventArgs e)
{       
    var carsFolder = HttpContext.Current.Request["customParam"] + "/";
     
    e.KeyName = string.Format("{0}{1}_{2}", carsFolder, Guid.NewGuid(), e.OriginalFileName);
}


Sample is attached.

Regards,
Hristo Valyavicharski
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
0
Tomasz
Top achievements
Rank 1
answered on 14 Jan 2014, 03:23 PM

But doesn't the SetKeyName method set the file name?

Let's say I have:

http://mydomain.blob.core.windows.net/mycontainer/

and now during upload I want to have such a structure created:



http://mydomain.blob.core.windows.net/mycontainer/folder_specified_by_the_user_in_text_field/original_file_name.extension

0
Hristo Valyavicharski
Telerik team
answered on 14 Jan 2014, 04:15 PM
Hi Tomasz,

The SetKeyName method specifies both the folder path and the file name. For example:
public override void SetKeyName(object sender, Telerik.Web.UI.CloudUpload.SetKeyNameEventArgs e)
{
    var carsFolder = HttpContext.Current.Request["customParam"] + "/";
    e.KeyName = string.Format("{0}{1}", carsFolder, e.OriginalFileName);
}


Regards,
Hristo Valyavicharski
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
0
Tomasz
Top achievements
Rank 1
answered on 14 Jan 2014, 04:58 PM

Great :)

0
TheLostLeaf
Top achievements
Rank 2
answered on 25 Sep 2014, 06:12 PM
Whenever I attempt this it just concatenates the container name and blob name together and puts the blob in the configured container folder in web.config. Any Ideas, using all latest Builds with VS 2013
0
Hristo Valyavicharski
Telerik team
answered on 26 Sep 2014, 12:02 PM
Hi TheLostLeaf,

What is the the value of the e.KeyName after you change it?

Regards,
Hristo Valyavicharski
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
CloudUpload
Asked by
Tomasz
Top achievements
Rank 1
Answers by
Hristo Valyavicharski
Telerik team
Tomasz
Top achievements
Rank 1
TheLostLeaf
Top achievements
Rank 2
Share this question
or