Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How add a file to an existing zip file using Golang

Tags:

zip

go

We can create a zip new file and add files using Go Language.

But, how to add a new file with existing zip file using GoLang?

If we can use Create function, how to get the zip.writer reference?

Bit confused.

like image 417
Aravind at Vembu Avatar asked Feb 14 '15 07:02

Aravind at Vembu


People also ask

Can you add a zip file to another zip file?

The easiest way to add files to an existing ZIP file is to drag and drop them on to the zipped file. You will see a '+Copy' tool tip. When you release your mouse and the files, they will be added to the zipped file. The files be added to the root of the zipped file.

How do I zip a file in Golang?

To zip a file or a directory in Go using the standard library, use zip. Writer type from the archive/zip package. Creating a compressed archive using this method involves going through all the files you want to include, generating a local file header for each one, and writing its contents to the resulting ZIP file.

How do I add files to an existing zip file in Linux?

Sometimes it's easy to delete a ZIP file and create a new one – say you've forgotten to include a file. Just drag it into the folder to be ZIPped up and start again.


1 Answers

After more analysis, i found that, it is not possible to add any files with the existing zip file.

But, I was able to add files with tar file by following the hack given in this URL.

like image 175
Aravind at Vembu Avatar answered Sep 28 '22 10:09

Aravind at Vembu