Reputation: 191
We have a C# windows console application that compress an SQlite file using System.IO.Compression.GZipStream. After compression of SQLite file, we are pushing the compressed file(.gzip) to a server where iOS will download it. Our problem is that after downloading the gzip file, the iOS can't uncompressed the file, it is getting UNZ_BADZIPFILE (-103) error. Our ios app is using SSZipArchive library to unzip the .gzip file. We tried to manually download the file in Mac machine and we are able to unzip the file. But in the iOS app it is getting an error. We are using SSZipArchive library to unzip the gzip file from Mac. Is there any encoding that we need to do so that the iOS app can recognized the gzip file created in windows machine?
Here is our code to compress the file in C# and produce a .gzip file.
FileInfo fileToBeGZipped = new FileInfo(filePath);
FileInfo gzipFileName = new FileInfo(string.Concat(fileToBeGZipped.FullName, ".gzip"));
using (FileStream fileToBeZippedAsStream = fileToBeGZipped.OpenRead())
{
using (FileStream gzipTargetAsStream = gzipFileName.Create())
{
using (GZipStream gzipStream = new GZipStream(gzipTargetAsStream, CompressionMode.Compress))
{
try
{
fileToBeZippedAsStream.CopyTo(gzipStream);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
}
}
IOS unzipping Code
if (![SSZipArchive unzipFileAtPath:[downloadedStoreURL path] toDestination:[destinationURL path] delegate:nil]) {
CLHLog(@"Couldn't unzip downloaded database");
return NO;
}
Error return from SSZipArchive
Error listing contents of archive: Error Domain=UZKErrorDomain Code=-103 "Bad zip file" UserInfo={NSLocalizedFailureReason=Bad zip file, NSLocalizedRecoverySuggestion=Error opening zip file /var/mobile/Containers/Data/Application/1DD4F888-0171-42D0-AC69-E0D497AC3943/Library/InspectionForms_compresed.sqlite.gzip, NSURL=file:///var/mobile/Containers/Data/Application/1DD4F888-0171-42D0-AC69-E0D497AC3943/Library/InspectionForms_compresed.sqlite.gzip, NSLocalizedDescription=Bad zip file}
Upvotes: 0
Views: 66