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

Implementation of chunk in rad upload control in asp.net vb.net

3 Answers 20 Views
Upload (Obsolete)
This is a migrated thread and some comments may be shown as answers.
Silver Lightning
Top achievements
Rank 1
Silver Lightning asked on 26 Aug 2014, 02:12 AM
Hi,

Great day.
I hope someone could help me.
I would like to upload selected files up to 500 MB using chunk and rebuild it and save to SQL database
I made some test but still did not make it correct. Does anyone know how to do it?

Here's my code in client side

 
<form id="form1" runat="server">
        <telerik:RadScriptManager runat="server" ID="RadScriptManager1" />
          <script src="scripts.js" type="text/javascript"></script>
 
            <div class="qsf-demo-canvas qsf-demo-canvas-vertical" style="margin-top: 50px">
                <telerik:RadAsyncUpload runat="server" ID="AsyncUpload1" ChunkSize="1048576"
                    OnClientFilesUploaded="fileUploaded"  OnFileUploaded="AsyncUpload1_FileUploaded" Localization-Select="Add" HttpHandlerUrl="~/Handler.ashx" />
                <telerik:RadProgressArea runat="server" ID="RadProgressArea1" />
            </div>
 
    </form>


Here's the Handler.ashx.vb but don't know what to do here..

Protected Overrides Function Process(ByVal file As UploadedFile, ByVal context As HttpContext, ByVal configuration As IAsyncUploadConfiguration, ByVal tempFileName As String) As IAsyncUploadResult
        ' Call the base Process method to save the file to the temporary folder
        ' base.Process(file, context, configuration, tempFileName);
 
        ' Populate the default (base) result into an object of type SampleAsyncUploadResult
        Dim result As AsyncUploadResult = CreateDefaultUploadResult(Of AsyncUploadResult)(file)
 
        
        ' Populate any additional fields into the upload result.
        ' The upload result is available both on the client and on the server
        'result.ImageID = InsertImage(file, userID)
 
        Return result
    End Function


Here's my code behind, what will I do here?

Protected Sub Page_Load(sender As Object, e As EventArgs)
      ' Populate the default (base) upload configuration into an object of type SampleAsyncUploadConfiguration
      Dim config As AsyncUploadConfiguration = AsyncUpload1.CreateDefaultUploadConfiguration(Of AsyncUploadConfiguration)()
 
      AsyncUpload1.UploadConfiguration = config
  End Sub
 
 
  Protected Sub AsyncUpload1_FileUploaded(sender As Object, e As FileUploadedEventArgs) Handles AsyncUpload1.FileUploaded
      Dim result As AsyncUploadResult = TryCast(e.UploadResult, AsyncUploadResult)
 
      Using stream As Stream = e.File.InputStream
          Dim imgData As Byte() = New Byte(stream.Length) {}
          stream.Read(imgData, 0, imgData.Length)
          Dim ms As New MemoryStream()
          ms.Write(imgData, 0, imgData.Length)
 
          Context.Cache.Insert(Session.SessionID + "UploadedFile", ms, Nothing, DateTime.Now.AddMinutes(20), TimeSpan.Zero)
      End Using
  End Sub


Thank you in advance... God bless



3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 1
answered on 26 Aug 2014, 09:22 AM
Hi,

Please have a look into this online demo which describes RadAsyncUpload with custom http handler.

Thanks,
Princy.
0
Silver Lightning
Top achievements
Rank 1
answered on 26 Aug 2014, 09:43 AM
Thanks Princy,

I already read that and not much helping me.
Can you give me an example on how could I chunk a file uploaded and rebuild it in handler.ashx.vb based on temporary file?

Once I rebuild that, I will insert it directly to SQL database.

Thank you and God bless in advance.


0
Nencho
Telerik team
answered on 28 Aug 2014, 02:41 PM
Hello,

Regardless if you try to upload the files on chunks it comes as one file to the process method in the handler. I am afraid that the control is design to work in such a manner and the functionality you desire, could not be achieved.

Regards,
Nencho
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
Upload (Obsolete)
Asked by
Silver Lightning
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 1
Silver Lightning
Top achievements
Rank 1
Nencho
Telerik team
Share this question
or