Aniruddha
Aniruddha

Reputation: 1039

Unable to open zip file created with ZipArchive on mainframe computer

Following is the code written in .Net Core, which creates a .zip file using ZipArchive. The strange thing is it unzips or opens perfectly on Windows or Linux machine, however it fails to unzip/open on a mainframe. Any suggestions or updates, that can be made to the code in order to resolve the issue?

Code:

public static async Task CreateZipFileAsync(string zipFileName, string bucket, List<string> pdfFileSet, IAmazonS3 s3Client)
{
    LambdaLogger.Log($"Zipping in progress for: {zipFileName}");
    using MemoryStream zipMS = new MemoryStream();
    using (ZipArchive zipArchive = new ZipArchive(zipMS, ZipArchiveMode.Create, true))
    {
        foreach (var pdfFile in pdfFileSet.Where(fileExt => !fileExt.EndsWith(".ECHOtrig")))
        {
                            
            GetObjectRequest request = new GetObjectRequest
            {
                BucketName = bucket,
                Key = pdfFile
            };

            using GetObjectResponse response = await s3Client.GetObjectAsync(request);
            using Stream responseStream = response.ResponseStream;
            ZipArchiveEntry zipFileEntry = zipArchive.CreateEntry(pdfFile.Split('/')[^1]);
                            
            //add the file contents
            using Stream zipEntryStream = zipFileEntry.Open();
            await responseStream.CopyToAsync(zipEntryStream);
        }
        zipArchive.Dispose();
    }
    zipMS.Seek(0, SeekOrigin.Begin);

    var fileTxfrToS3 = new TransferUtility(s3Client);
    await fileTxfrToS3.UploadAsync(zipMS, bucket, $"{Function.prefix}{zipFileName}");
    LambdaLogger.Log($"Successfully created {zipFileName}");             
}

Upvotes: 0

Views: 417

Answers (2)

Stephen Cleary
Stephen Cleary

Reputation: 456322

It's probably because the mainframe only understands an older ZIP file version. There have been several modifications to the ZIP file format over the years. In my experience, the ones most likely to cause a problem are:

  1. 64-bit zip format (usually only used for large files).
  2. UTF-8 filename encoding.
  3. Encryption and signatures.
  4. Unsupported compression/hash/encryption algorithms.

Upvotes: 1

Lex Li
Lex Li

Reputation: 63123

Unfortunately Microsoft does not officially support .NET Core on mainframe,

https://github.com/dotnet/core/blob/main/release-notes/6.0/supported-os.md

and

https://github.com/dotnet/runtime/issues/34195

Upvotes: 1

Related Questions