获取用PHP保存在vb.net和ICSharpCode.SharpZipLib.Zip.ZipInputStream中的图像

时间:2019-02-19 14:52:50

标签: php vb.net zipoutputstream

我一直坚持将VB.net中生成的数据集成到新的php应用程序中。

我有两个函数用于压缩和解压缩数据(例如图像):

''' <summary>
''' Compress data into zip
''' </summary>
''' <param name="bin">input byte array</param>
''' <returns>output byte array</returns>
''' <remarks></remarks>
Public Shared Function CompressData(ByVal bin() As Byte) As Byte()
    Dim buffer(1024 * 4 - 1) As Byte

    Dim mout As New System.IO.MemoryStream()
    Using zout As New ICSharpCode.SharpZipLib.Zip.ZipOutputStream(mout)
        zout.SetLevel(9)
        Using min As New System.IO.MemoryStream(bin)
            Dim zentry As New ICSharpCode.SharpZipLib.Zip.ZipEntry(String.Empty)
            zout.PutNextEntry(zentry)
            ICSharpCode.SharpZipLib.Core.StreamUtils.Copy(min, zout, buffer)
        End Using
        zout.Finish()
    End Using

    Return mout.ToArray()
End Function

''' <summary>
''' Uncompress data from zip
''' </summary>
''' <param name="bin">input byte array</param>
''' <returns>output byte array</returns>
''' <remarks></remarks>
Public Shared Function DecompressData(ByVal bin() As Byte) As Byte()
    Dim buffer(1024 * 4 - 1) As Byte

    Dim mout As New System.IO.MemoryStream()

    Using zin As New ICSharpCode.SharpZipLib.Zip.ZipInputStream(New System.IO.MemoryStream(bin))
        Dim zentry As ICSharpCode.SharpZipLib.Zip.ZipEntry = zin.GetNextEntry()
        Do While zentry IsNot Nothing
            If zentry.IsFile Then
                ICSharpCode.SharpZipLib.Core.StreamUtils.Copy(zin, mout, buffer)
                Exit Do
            End If
        Loop
    End Using

    Return mout.ToArray()
End Function

在数据库中,我具有由CompressData函数生成的base64编码文本,并且能够读取和base64_decode文本。

有什么想法可以用PHP找回原始文件吗?

干杯!

0 个答案:

没有答案