Home Forums .NET libraries Xceed Zip & Real-Time Zip for .NET Compress binary from database -unknown or damaged file error

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #19862 |

    We are storing document files (images, pdf, etc) as binary in the database. I would like to compress and then stream the compressed byte to the client for download.

    The download code is functional, however the resulting compressed file is “unknown format or damaged”. I am certain the file is not corrupt, as I am able to successfully stream an uncompressed image to the browser and download it as well.

    Am I missing something in the compression? There is nothing in the documentation other than the single method call. Thank you for your help.

    Private Sub DownloadFile()
    Dim bytes As Byte()
    Dim output As Byte()

    Try
    ‘get file binary from DAM
    bytes = m_DamHelper.GetFileImageData(m_FileID)
    Catch
    bytes = Nothing
    Exit Sub
    End Try

    If m_Uncompressed Then
    m_FileExt = “pdf”
    output = bytes
    Else
    Xceed.Compression.Licenser.LicenseKey = “REMOVED”
    [b]output = QuickCompression.Compress(bytes, CompressionMethod.Deflated, CompressionLevel.Normal)[/b]
    End If

    Try
    With Response
    .ClearHeaders()
    .BufferOutput = True
    .ContentType = “application/” + m_FileExt
    .Cache.SetCacheability(HttpCacheability.NoCache)
    .AppendHeader(“content-disposition”, “attachment; filename=file.” + m_FileExt)
    .BinaryWrite(output)
    End With
    Catch
    ‘error during download
    Finally
    Response.Flush()
    Response.End()
    End Try

    End Sub

    Imported from legacy forums. Posted by SokViChet (had 2915 views)

    User (Old forums)
    Member
    Post count: 23064

    btw, i incorrectly tagged the line i wish to highlight. I do not have the [b][/b] in my code, of course.

    Imported from legacy forums. Posted by SokViChet (had 242 views)

    Xceed Support
    Member
    Post count: 5658

    I tried reproducing this error and I was not able to. I did the same kind of process using QuickCompression and also tested it with XceedCompressedStream. Both method were able to compress and decompress the byte arrays without any glitch.

    Imported from legacy forums. Posted by CharlesB (had 3670 views)

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.