Compressing and uploading on the APP end and decompressing on the PHP end. 1. interaction between android and php
Java
String body = "Lorem ipsum shizzle ma nizle"; URL url = new URL ("http://some.url/file.php? Id = "+ uid); URLConnection conn = url. openConnection (); conn. setDoOutput (true); conn. setRequestProperty ("Content-encoding", "deflate"); conn. setRequestProperty ("Content-type", "application/octet-stream"); DeflaterOutputStream dos = new DeflaterOutputStream (conn. getOutputStream (); dos. write (body. getBytes (); dos. flush (); dos. close ();
Php
$ Content = http_get_request_body (); $ uncontent = gzuncompress ($ content );
2. interaction between ios and php
Php receives gzip compression
Gzdecode (base64_decode ($ json); // ios gzip uncompress
Php receives zlib compression
Gzuncompress (base64_decode ($ json); // ios zlib uncompress