Change name of file before uploading to Azure.

5 posts, 1 answers
  1. Vance Smith
    Vance Smith avatar
    36 posts
    Member since:
    Jun 2012

    Posted 26 Oct 2013 Link to this post

    Hi, is it possible to change the name of the file before uploading to Azure?
  2. Answer
    Peter Filipov
    Admin
    Peter Filipov avatar
    1028 posts

    Posted 28 Oct 2013 Link to this post

    Hi Vance,

    I am sending you a sample project which shows how to change the name of the uploading file.

    Regards,
    Peter Filipov
    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. Vance Smith
    Vance Smith avatar
    36 posts
    Member since:
    Jun 2012

    Posted 30 Oct 2013 Link to this post

    Thanks! This gets me closer... :-)
  5. Geraldo Santos
    Geraldo Santos avatar
    3 posts
    Member since:
    Feb 2010

    Posted 10 Dec 2013 Link to this post

    I need to change the file name based on a parameter passed by url
    but the class does not allow me to access the request.
    how can I get access to session variables or passed in the url within the parameters Telerik.Web.UI.CloudUploadHandler class?

    see my code below.


    Imports System
    Imports System.Web
    Imports System.Web.Services

    Public Class vendedores_img : Inherits Telerik.Web.UI.CloudUploadHandler

        Public Overrides Sub SetKeyName(sender As Object, e As Telerik.Web.UI.CloudUpload.SetKeyNameEventArgs)

            e.KeyName = "vendedores-img-pg/" & e.OriginalFileName

        End Sub
        Public Overloads Sub ProcessRequest(context As System.Web.HttpContext)
            Dim vID As String = context.Request.QueryString("ContaID")
            e.KeyName = vID
    'Not that performing this procedure *
        End Sub

    End Class
  6. Peter Filipov
    Admin
    Peter Filipov avatar
    1028 posts

    Posted 11 Dec 2013 Link to this post

    Hello Vance,

    At the moment this functionality is not implemented yet. However you could use the following workaround.
    Handle OnClientFileSelected event and modify the handler as pass extra information as a Query String:
    <telerik:RadCloudUpload ID="RadCloudUpload1" runat="server" ProviderType="Azure"
                MultipleFileSelection="Automatic" OnClientFileSelected="onClientFileSelected"
                HttpHandlerUrl="~/Handlers/UploadToMultipleFoldersHandler.ashx">
            </telerik:RadCloudUpload>

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

    <%@ WebHandler Language="C#" Class="UploadToMultipleFoldersHandler" %>
      
    using System;
    using System.Web;
      
    public class UploadToMultipleFoldersHandler : Telerik.Web.UI.CloudUploadHandler {
      
        public override void SetKeyName(object sender, Telerik.Web.UI.CloudUpload.SetKeyNameEventArgs e)
        {
            var param = HttpContext.Current.Request["customParam"];
                   
            var carsFolder = HttpContext.Current.User.Identity.Name + "/";
            e.KeyName = string.Format("{0}{1}_{2}", carsFolder, Guid.NewGuid(), e.OriginalFileName);
        }  
    }

    This feature has already been requested and submitted into our tracking system. It will be implemented in some of the next versions of the control.

    In case that you want to access the session state in the handler, the handle should implement the following interface IRequireSessionState.

    Regards,
    Peter Filipov
    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.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017