Custom folder name in Azure

7 posts, 0 answers
  1. Tomasz
    Tomasz avatar
    20 posts
    Member since:
    Apr 2012

    Posted 14 Jan 2014 Link to this post

    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?



  2. Hristo Valyavicharski
    Admin
    Hristo Valyavicharski avatar
    975 posts

    Posted 14 Jan 2014 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Tomasz
    Tomasz avatar
    20 posts
    Member since:
    Apr 2012

    Posted 14 Jan 2014 Link to this post

    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

  5. Hristo Valyavicharski
    Admin
    Hristo Valyavicharski avatar
    975 posts

    Posted 14 Jan 2014 Link to this post

    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.
  6. Tomasz
    Tomasz avatar
    20 posts
    Member since:
    Apr 2012

    Posted 14 Jan 2014 Link to this post

    Great :)

  7. TheLostLeaf
    TheLostLeaf avatar
    34 posts
    Member since:
    Feb 2007

    Posted 25 Sep 2014 in reply to Hristo Valyavicharski Link to this post

    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
  8. Hristo Valyavicharski
    Admin
    Hristo Valyavicharski avatar
    975 posts

    Posted 26 Sep 2014 Link to this post

    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.

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