zlib

How can one copy the internal state of zlib compressor object in Python

孤人 提交于 2019-12-12 18:34:24
问题 I have to compress a long list of strings. I have to compress them individually. Each string is less than 1000 chars long. However many of these strings have a common prefix. Therefore I was wondering if I could amortize the compression cost, by compressing the common prefix first and then storing the state of the compressor and feed it the suffix of the strings. If you have any suggestions about how to accomplish this in Python that would be great. Although I mention zlib in the title any

Rails: how to unzip a compressed xml request body?

本秂侑毒 提交于 2019-12-12 17:17:08
问题 I have a rails 3 site which gets xml requests (incluing file submissions) from an iphone app. The iphone app compresses the body of its xml requests, which come through to my controller like this (this is a simple one that just updates a couple of details rather than sends any files): params = {"\x1F\x8B\b\x00\x00\x00\x00\x00\x00\x035\xCAA\x0E\x83 \x10@\xD1\xD3\xE8\xD20\x02R\x17\xDD4\xBD\x87\x01\x9CZ\"H\x03CHo\xDF\xB2`\xFB\xDFO\xF8\x89\x89\x06\xF9\xA81\x9D/\x1F\xEB\x96IS\xC9\x83|\xDE\xF9\x98

Decompressing gzipped data with Inflater in Java

試著忘記壹切 提交于 2019-12-12 13:01:11
问题 I'm trying to decompress gzipped data with Inflater . According to the docs, If the parameter 'nowrap' is true then the ZLIB header and checksum fields will not be used. This provides compatibility with the compression format used by both GZIP and PKZIP. Note: When using the 'nowrap' option it is also necessary to provide an extra "dummy" byte as input. This is required by the ZLIB native library in order to support certain optimizations. Passing true to the constructor, then attempting to

Postgres' text column doesn't like my zlib compressed data

陌路散爱 提交于 2019-12-12 11:42:33
问题 Is there a better data type to be using to store a zlib compressed string in Postgresql? 回答1: Use bytea "The bytea data type allows storage of binary strings" 回答2: Use a bytea. Zip compressed data is not a text. 来源: https://stackoverflow.com/questions/2958073/postgres-text-column-doesnt-like-my-zlib-compressed-data

What might explain an “invalid stored block lengths” error?

空扰寡人 提交于 2019-12-12 11:01:52
问题 I am running a Rails (3.2.3) application with Ruby 1.9.3p194 on the basic Ubuntu lucid32 image in a Vagrant virtual box. The virtual box is running on Leopard, for what it's worth. I'm trying to use rubyzip in the application to decompress a zip archive - 2009_da_lmp.zip . Using code directly from examples in the rubyzip repository, I can confirm that I can list the archive file contents: #f is the absolute path to 2009_da_lmp.zip (string) Zip::ZipFile.open(f) { |zf| zf.entries[0] } =>

Using zlib to compress a directory

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-12 10:40:13
问题 I have a C++ application that requires using a standard compression format for a directory. I thought about using zip format. And therefore, zlib was obvious. My problem is building the dictionary, i.e. compressing a directory containing some files with zlib to a standard zip file. I have read that zlib does it but I don't understand how. I've checked minzip code. It seems to use gzip. I could build my own format but I want to be able to open these files using 7z for debugging (just in case).

php zlib: How to dynamically create an in-memory zip files from string variables?

こ雲淡風輕ζ 提交于 2019-12-12 09:09:19
问题 this is what I need $a=array('folder'=>'anyfolder','filename'=>'anyfilename','filedata'=>'anyfiledata'); I need to create a variable $zip with compressed data from $a and output this $zip into browser window with header('Content-type: application/octetstream'); echo $zip; All libs that I found, they pack files and create zip files physically on disk. I need to do it dynamically, using memory. Is there any examples of how to do it using pure php's zlib and without studying the zip format

What is the inverse of crc32_combine()'s matrix trick?

落爺英雄遲暮 提交于 2019-12-12 08:14:19
问题 zlib's crc32_combine() takes crcA, crcB, and lengthB to calculate crcAB. # returns crcAB crc32_combine(crcA, crcB, lenB) Using concepts from Mark Adler's awesome posts here and here I was able to produce crc32_trim_trailing.pl which takes crcAB, crcB, and lengthB to calculate crcA (I use this to peel off padding of a known length and value). # prints crcA perl crc32_trim_trailing.pl $crcAB $crcB $lenB Unfortunately, this uses the principles of the slow method described, where each null byte

What easy zlib tutorials are there?

╄→гoц情女王★ 提交于 2019-12-12 07:08:27
问题 I'm looking for a good tutorial on zlib. I'm interested only in decompressing the archives. I also want to know how I can access a desired file inside an archive, preferably by filename alone, if that can be done in zlib at all. 回答1: Well there are many zlib articles , tips and tutorials. Some of them are 1) Bobobobo's Blog Website: http://bobobobo.wordpress.com/2008/02/23/how-to-use-zlib/ This article basically tells you how to use zlib, and there is a snippet of code that will get you going

Decompress with gz* functions succeeded but failed with inflate* functions using zlib

☆樱花仙子☆ 提交于 2019-12-12 05:18:15
问题 I have a gzip file sample, with standard gzip header 1F 8B 08 00 ... , when I inflate it with inflate* functions in zlib, the output is only 11 bytes(in fact the output should be about 4KB), but when I decompress it with gz* functions, it produce the correct output, the code: using gz* (this can produce correct output): #define CHUNK 10240 int gz_decompress(const char *path) { gzFile f = gzopen(path, "rb"); if(!f) return -1; unsigned char result[CHUNK]; int bytes_read = gzread(f, result,