Async content stream length issue

2 posts, 0 answers
  1. Ed Hand
    Ed Hand avatar
    2 posts
    Member since:
    Jan 2010

    Posted 07 Mar 2013 Link to this post

    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?
  2. Ed Hand
    Ed Hand avatar
    2 posts
    Member since:
    Jan 2010

    Posted 08 Mar 2013 Link to this post

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