0

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}

ramdev
  • 137
  • 1
  • 9
  • If the archive can be opened on a Mac, it doesn’t seem likely that there’s anything wrong with it, does it? Isn’t the problem more likely with the iOS app? How does it do with files created on the Mac, using the command line, for instance? Is it possibly not opening the file it’s supposed to be, or not downloading it successfully, or something like that? – padeso May 10 '23 at 15:40
  • the file was successfully downloaded. The error happen during unzipping the file in the iOS. – ramdev May 10 '23 at 15:48
  • If the problem is in the iOS code, you might consider including it with your question. – padeso May 10 '23 at 16:57
  • I added the code in Mac – ramdev May 11 '23 at 18:18

0 Answers0