From f08466e1867e159dbf536b0783219cfac4272de1 Mon Sep 17 00:00:00 2001 From: jano3 <jano@bob.co.za> Date: Thu, 9 May 2024 13:30:39 +0200 Subject: [PATCH] New function: AddFileToZipWithHeader --- zip_utils/zip_utils.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/zip_utils/zip_utils.go b/zip_utils/zip_utils.go index 7edc3e6..9cf328a 100644 --- a/zip_utils/zip_utils.go +++ b/zip_utils/zip_utils.go @@ -3,6 +3,7 @@ package zip_utils import ( "archive/zip" "bytes" + "gitlab.bob.co.za/bob-public-utils/bobgroup-go-utils/date_utils" "io" "time" ) @@ -71,7 +72,12 @@ func readZipFile(zipFile *zip.File) ([]byte, error) { } func AddFileToZip(fileName string, fileBytes []byte, zipWriter *zip.Writer) error { - file, err := zipWriter.Create(fileName) + header := &zip.FileHeader{ + Name: fileName, + Method: zip.Deflate, + Modified: date_utils.CurrentDate(), + } + file, err := zipWriter.CreateHeader(header) if err != nil { return err } -- GitLab