Found the problem. ObjectMetadata
requires the content-type / encoding to be set explicitly rather than via addUserMetadata()
. Changing the following:
metadata.addUserMetadata("Content-Encoding", "gzip");
metadata.addUserMetadata("Content-Type", "application/x-gzip");
to:
metadata.setContentEncoding("gzip");
metadata.setContentType("application/x-gzip");
fixed this.