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

Async content stream length issue

1 Answer 71 Views
AsyncUpload
This is a migrated thread and some comments may be shown as answers.
Ed Hand
Top achievements
Rank 1
Ed Hand asked on 08 Mar 2013, 02:29 AM

I just found a possible issue with the reported upload file's stream length. My initial attempts to determine what was going on can be reviewed over on the MSDN forums here:

http://social.msdn.microsoft.com/Forums/en-US/sqlsearch/thread/877d4ba7-3028-4bc2-aeec-e61b0da62526

In short I am putting uploaded documents into a varbinary(max) column on a SQL table. The column is set for full text indexing and while older .doc files along with .txt, .aspx, and other extensions would work just fine. The new Office formats (.docx, .xlsx, etc.) were not indexing. I thought at first it was an issue with the installation of the needed Office filter pack, but that turns out not to be the case.

Rather if I create my byte array to pass to SQL as one byte less than reported by the stream, then everything works. i.e.:

Protected Sub AsyncUpload1_FileUploaded(sender As Object, e As Telerik.Web.UI.FileUploadedEventArgs) Handles AsyncUpload1.FileUploaded
     DocumentTable.UpdateDocumentFile(e.File.InputStream)
 End Sub
  
Public Sub UpdateDocumentFile(ByRef content As IO.Stream)
     Dim bytes As Byte() = New Byte(content.Length - 1) {}
     content.Read(bytes, 0, content.Length)
     SqlHelper.ExecuteNonQuery(getConnectionString, _
                                "Documents_Upsert", _
                               Me.DocumentId, _
                               Me.Filename, _
                               Me.Extension, _
                               Me.MimeType, _
                               bytes)
 End Sub

Any ideas or observations?

1 Answer, 1 is accepted

Sort by
0
Ed Hand
Top achievements
Rank 1
answered on 09 Mar 2013, 01:08 AM
Nevermind... forgot I was in VB and didn't remember silly VB'ism that it isn't the lengh but the last addressable slot that your passing in.
Tags
AsyncUpload
Asked by
Ed Hand
Top achievements
Rank 1
Answers by
Ed Hand
Top achievements
Rank 1
Share this question
or