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

Change name of file before uploading to Azure.

8 Answers 102 Views
CloudUpload
This is a migrated thread and some comments may be shown as answers.
Vance Smith
Top achievements
Rank 1
Vance Smith asked on 26 Oct 2013, 05:14 AM
Hi, is it possible to change the name of the file before uploading to Azure?

8 Answers, 1 is accepted

Sort by
0
Accepted
Peter Filipov
Telerik team
answered on 28 Oct 2013, 09:50 AM
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.
0
Vance Smith
Top achievements
Rank 1
answered on 30 Oct 2013, 05:13 AM
Thanks! This gets me closer... :-)
0
Geraldo Santos
Top achievements
Rank 1
answered on 10 Dec 2013, 04:08 PM
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
0
Peter Filipov
Telerik team
answered on 11 Dec 2013, 10:55 AM
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.
0
Michael
Top achievements
Rank 1
answered on 23 Dec 2016, 04:48 PM
Trying to what Vance did except using vb.net and Amazon s3,  do you have an example of this
0
Veselin Tsvetanov
Telerik team
answered on 27 Dec 2016, 01:13 PM
Hi Michael,

The implementation of the Custom upload handler for Amzon S3 should not be different from the one, included in the example. If you need to convert code from C# to VB and vice-versa, you could use our online Code converter. You could also find the VB version of the example in our Documentation.

Regards,
Veselin Tsvetanov
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Greg
Top achievements
Rank 1
answered on 06 Jan 2020, 08:17 PM

In the above post from 11 Dec 2013 you mention:

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.

 

Has it been implemented, or is the OnClientFileSelected approach you mentioned still the best way to pass information to the handler?

0
Peter Milchev
Telerik team
answered on 09 Jan 2020, 09:11 AM

Hello Greg,

Unfortunately, the approach mentioned in this thread is the way to go.

I have created a public feedback portal item for this feature request which you can follow and vote for.

Regards,
Peter Milchev
Progress Telerik

Get quickly onboarded and successful with UI for ASP.NET AJAX with the Virtual Classroom technical trainings, available to all active customers. Learn More.
Tags
CloudUpload
Asked by
Vance Smith
Top achievements
Rank 1
Answers by
Peter Filipov
Telerik team
Vance Smith
Top achievements
Rank 1
Geraldo Santos
Top achievements
Rank 1
Michael
Top achievements
Rank 1
Veselin Tsvetanov
Telerik team
Greg
Top achievements
Rank 1
Peter Milchev
Telerik team
Share this question
or