1024jp / GzipSwift

Swift package that enables gzip/gunzip Data using zlib
MIT License
547 stars 133 forks source link

Incorrect header #8

Closed Hakkoos closed 7 months ago

Hakkoos commented 8 years ago

I am getting Incorrect Header and also data1!.isGzipped is always returning true for my data. This is what I tried:

I am using this code

let data1 = rootArr.data(using: String.Encoding.utf8, allowLossyConversion: true) if data1!.isGzipped { let unzippedData = try! data1!.gunzipped() print(unzippedData) }

  1. Tried this before the above code let rootArr = "CwAAAB+LCAAAAAAABADzSM3JyVcIzy/KSQEAVrEXSgsAAAA" The text is "Hello world" gzipped using .NET C# so it is base64 I believe
  2. Tried this before the above code let rootArr = "0x1F8B0800000000000400CB48CDC9C95728CF2FCA49010085114A0D0B000000" The text is "Hello world" gzipped using SQL Server 2016 Compress method

The method isGzipped is looking for anything starting with 0x1f but by the time I convert my string to NSData the encoding will result in the 01xf lost? I am not savvy with encoding.

This is my testing but in real app the data I am bringing from the server is a large json 15MB. I need to break it up and retrieve portions of it that have been zipped and unzip these. When retrieving json I get nsstring and I am trying to convert that to NSData to feed to the GZipSwift

Could anybody tell me how that can be done please

Cheers

Hakkoos commented 8 years ago

I meant to say also data1!.isGzipped is always returning FALSE

kolega69 commented 8 years ago

Try this for the inflate: status = inflateInit2_(&stream, -MAX_WBITS, ZLIB_VERSION, STREAM_SIZE)

And for the deflate: status = deflateInit2_(&stream, level, Z_DEFLATED, -MAX_WBITS, MAX_MEM_LEVEL, Z_DEFAULT_STRATEGY, ZLIB_VERSION, STREAM_SIZE)

1024jp commented 7 months ago

This issue was closed because it has been inactive for years since the last update and may be outdated. Please post a new comment if you still have an issue.