1

I'm trying to configure apache in order to uncompress .kmz files served to the client application (I want to avoid dealing with additional js libraries).

I've mod_deflate enabled and I added that configuration:

#kmz files handling
<FilesMatch "[^.]+\.kmz$">
    SetOutputFilter INFLATE
</FilesMatch>

The response remains compressed and the client application cannot read data. What I'm doing wrong?

Thank you.

dorje
  • 11
  • 1

1 Answers1

0

mod_deflate only supports the gzip encoding, but from what I can tell, .kmz files are Zip-encoded:

$ file test.gz
test.gz: gzip compressed data, was "test", from Unix, last modified: Thu Nov  5 10:38:11 2020
$ file test.kmz
test.kmz: Zip archive data, at least v2.0 to extract

So I think you need a different output filter:

ExtFilterDefine unzip-kmz \
  intype=application/vnd.google-earth.kmz \
  outtype=application/vnd.google-earth.kml+xml \
  cmd=/usr/bin/gunzip
AddOutputFilter unzip-kmz kmz

Or more simply:

ExtFilterDefine gunzip cmd=/usr/bin/gunzip
AddOutputFilterByType gunzip application/vnd.google-earth.kmz

That might work, but it doesn't specify the output content type, so if Apache doesn't get that right, you'll need to use the first form.

Notes:

  • gunzip will decompress Zip-encoded data, but you could also use unzip.
  • Make sure that the intype and outtype parameter values are the right content types for your system. grep '\.km[lz]' /etc/mime.types will show you.
Andrew Schulman
  • 8,561
  • 21
  • 31
  • 47