I've already tried zlib_encode($data,15);
, zlib_encode($data,31);
and bzcompress($data,9);
writing result into file. Everything looks good but I'm not able to decompress any of them with python. Bz2 gives me OSError: Invalid data stream
, gzip gives me CRC check failed
, zlib gives me Error -3: invalid literal/length
. But when I'm trying bzopen()
and bzwrite()
I'm able to decompress file in python. The only problem that I have to open file to add new data at the end of file, but bzopen fully rewrites file.
So am I able to decompress data compressed with php using python?
My python version is 3.5
Some python code
import bz2
f=open('filename', 'rb')
data = f.read() # data now contains bytes
print(bz2.decompress(data))
That's all because I've tried to decompress file from python console
And some php code
<?php $data=$_POST['data'];
$fp = fopen('filename', 'a');
fwrite($fp, bzcompress($data, 9));
fclose($fp); ?>
Php code is running on the Linux system and I'm getting the file via ftp on my windows machine with python