FAQ Database Discussion Community


Read and Modify content of inner zip file using ZipInputStream

java,file,zipfile,zipinputstream
I am trying to modify web.xml using ZipInputStream. File to read is web.xml which is inside ear/war file C:/XX.ear/YY.war/WEB-INF/web.xml ZipFile zipFile = new ZipFile("C:/XX.ear"); Enumeration<? extends ZipEntry> entries = zipFile.entries(); while(entries.hasMoreElements()){ ZipEntry entry = entries.nextElement(); if(entry.getName().equalsIgnoreCase("YY.war")){ ZipInputStream inputStream = new ZipInputStream(zipFile.getInputStream(entry)); ZipEntry zipEntry; while(( zipEntry = inputStream.getNextEntry())!=null) {...

Zipfile not writing data - Python

python,logging,zip,zipfile
I have tried to zip log files that I have created, but nothing is written! Code: def del_files(): '''Adapted from answer @ http://stackoverflow.com/questions/7217196/python-delete-old-files by jterrace''' dir_to_search = os.path.join(os.getcwd(),'log') for dirpath, dirnames, filenames in os.walk(dir_to_search): for file in filenames: curpath = os.path.join(dirpath, file) log(curpath) if curpath != path: log("Archiving old log...

Accessing .zipx with Python

python,zipfile
I'm attempting to write a very simple script that counts the number of entries/files a given ZIP file has, for some statistics. I'm using the zipfile library, and I'm running into this problem where the library appears not to support .zipx format. bash-3.1$ python zipcount.py t.zipx Traceback (most recent call...

Feature-specific compatibility of a .NET 4.5 application on a system with .NET 4.0

c#,.net,zipfile
I have a project which runs fine on 4.0, however in the interests of utilizing the new ZipFile class I have decided to target 4.5. The vast majority of my users will have 4.5+ installed, but its not impossible someone with only 4.0 may come along and try to use...

VBA fails to limit to just .dat files if there are zip files present in the folder

vba,filter,folder,zipfile
I have added a filter to the type of files allowed to selected (.dat files) however I have found that if there are zip files present in the folder the script does not work correctly as it also opens the zip files. 'Specify folder where measurement files are stored With...

A simple Script to extracting a zip file

python,unzip,zipfile,xbmc,kodi
Good Evening all, I think I'm not understanding the zipfile structure properly heres the code import xbmc import zipfile targetzip = xbmc.translatePath('special://home/userdata/addon_data/plugin.program.tester/test.zip') extractto = xbmc.translatePath('special://home/userdata/addon_data/plugin.program.tester/') zip = ZipFile(targetzip) zip.extractall(extractto) Any Ideas why Its not working?...

Create symlink inside a zipfile in memory using python

python,memory,symlink,zipfile
I am looking for a way to create a zipfile in memory and include a symlink inside the zipfile. So far I have found this link and try the following code: from zipfile import ZipInfo from zipfile import ZipFile from zipfile import ZIP_DEFLATED, ZIP_STORED from cStringIO import StringIO import codecs...

How do I extract a file with the python zipfile library while changing it's name

python,zip,zipfile
This is motivated by pathfile issues (unfortunately this doesn't seem to be true in my case). I have a zipfile that I am trying to extract with python. The zipfile appears to have been created on windows. The code I have to extract the files from the zipfile is like...

how to download a zip file using angular

angularjs,asp.net-web-api,httpresponse,zipfile,pushstreamcontent
I am trying to download a zip file from my web api controller. It is returning the file but I am getting a message the zipfile is invalid when i try to open. I have seen other posts about this and the response was adding the responseType: 'arraybuffer'. Still isn't...

Java: Zip file with non-static filename

java,directory,zip,zipfile
I found this ZipUtils class on this post: how to zip a folder itself using java I modified it so I could pass a zip file name. However, the only way it works is with a hardcoded static string. The zippedFile string is grabbed from the database. I have compared...

Python zipfile compress_size returns 'int' object is not callable

python,zipfile
I am trying to get the compressed size of a file with Python and zipfile zip = zipfile.ZipFile('test.zip') namelist = zip.namelist() for fn in namelist: print fn print zip.getinfo(fn).compress_size() I get the error TypeError: 'int' object is not callable What is the reason for that?...

Python and the zipfile module

python,python-2.7,zipfile
According to Python documentation: ZipFile.extract(member[, path[, pwd]]) Extract a member from the archive to the current working directory; member must be its full name or a ZipInfo object). Its file information is extracted as accurately as possible. path specifies a different directory to extract to. member can be a filename...

PyInstaller IO Error accessing zip

wxpython,pyinstaller,zipfile
I have a wxpython program where I keep the picture files in a zip file. Program runs fine while running by python. But when I run pyinstaller to produce exe file, I get IO error. Here is my program. import zipfile import wx from PIL import Image from StringIO import...

Pdfs inside zip file are corrupted

c#,web-api,ionic,zipfile,pushstreamcontent
I am trying to make a zip file that contains pdfs. When i extract the zip, the pdfs are corrupted. I placed a watch on 'outputStream'. Here is the first exception 'outputStream.Length' threw an exception of type 'System.NotSupportedException' long here is the entire watch Code [HttpPost] [ActionName("ZipFileAction")] public HttpResponseMessage ZipFiles([FromBody]int[]...

Java: any way to get a ZipFile (or anything with a direct getEntry method) from a byte array?

java,arrays,byte,zipfile
I have the contents of a zip file in a byte array. The file contains a number of entries (typically about 12), but I only care about three of them. I would like to somehow get this into a ZipFile object, so I can pull those specific three ZipEntrys out...

Create individual archives from individual folders with Zipfile

python,zipfile
I have a directory composed of 3 folders : ----- 001 ----- 002 ----- 003 I'd like to create 3 archives named 001.zip, 002.zip and 003.zip. Each archive has to be composed of the content of the folder. I use the zipfile library and I managed to make an archive...

Adding large files to IO.Compression.ZipArchiveEntry throws OutOfMemoryException Exception

c#,out-of-memory,zipfile
I am trying to add a large video file(~500MB) to an ArchiveEntry by using this code: using (var zipFile = ZipFile.Open(outputZipFile, ZipArchiveMode.Update)) { var zipEntry = zipFile.CreateEntry("largeVideoFile.avi"); using (var writer = new BinaryWriter(zipEntry.Open())) { using (FileStream fs = File.Open(@"largeVideoFile.avi", FileMode.Open)) { var buffer = new byte[16 * 1024]; using (var...