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

RadAsyncUpload control - content type

1 Answer 215 Views
AsyncUpload
This is a migrated thread and some comments may be shown as answers.
Keith Jusas
Top achievements
Rank 1
Keith Jusas asked on 26 Jul 2011, 02:21 PM
Hi,

I would like to use RadAsyncUpload control to upload multiple files to Amazon S3. I have included RadAsyncUpload control in my web application. I am able to select multiple files to upload and it uploads the selected files successfully to Amazon S3 ( it stores the files temporarily to temp folder) but when I try to download files from amazon S3, I get the corrupted file as the contenttype of the file never gets set properly. I am using the serverside event . "FileUploaded" to get the selected file's name, content type and content length. The content length is returned as an integer and when I convert that into the byte(), it gives me the wrong result. Here is my code:

 

 

 

Protected Sub RadAsyncUpload1_FileUploaded(ByVal sender As Object, ByVal e As Telerik.Web.UI.FileUploadedEventArgs) Handles RadAsyncUpload1.FileUploaded

        Dim counter As Integer = Session("counter")

        Dim newrow As DataRow = dt.NewRow
        Dim buffer As Byte() = New Byte(e.File.ContentLength - 1) {}

        If e.IsValid Then
            S3Conn = New AWSAuthConnection(S3AWSAccessKeyId, S3SecretAccessKeyId)
            counter = counter + 1

            If Not S3Conn Is Nothing Then
                S3Conn.createBucket(S3Bucket, Nothing)

                Dim metadata As SortedList = New SortedList()
                metadata.Add("filename", e.File.FileName)

                Dim s3key As String = "test/" & Session("dbid") & "_" & Session("recid") & "_" & CStr(counter)
                Dim obj As S3Object = New S3Object(buffer, metadata)

                Dim headers As New SortedList
                headers.Add("Content-Type", buffer)
                headers.Add("x-amz-acl", "public-read")

                S3Conn.put(S3Bucket, s3key, obj, headers)
            End If
            Session("counter") = counter
            S3Conn = Nothing
        End If

       
    End Sub

1 Answer, 1 is accepted

Sort by
0
Peter Filipov
Telerik team
answered on 27 Jul 2011, 01:41 PM
Hello Keith Jusas,

As far as I investigate your code I noticed that the buffer variable is only instantiated, no data is added to the array.
In the following line : headers.Add("Content-Type", buffer) , content type is set to the buffer variable. About AWAuthConnection class I have consulted with the following link.

Greetings,
Peter Filipov
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Tags
AsyncUpload
Asked by
Keith Jusas
Top achievements
Rank 1
Answers by
Peter Filipov
Telerik team
Share this question
or