ホームページ  >  記事  >  バックエンド開発  >  APP側でアップロードを圧縮し、PHP側で解凍します

APP側でアップロードを圧縮し、PHP側で解凍します

WBOY
WBOYオリジナル
2016-06-23 13:08:24796ブラウズ

1. Android と 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. iOS と php の間の相互作用

php は gzip 圧縮を受け取ります

gzdecode(base64_decode($json));//ios gzip uncompress

php は zlib 圧縮を受け取ります

gzuncompress(base64_decode($json));//ios zlib uncompress


声明:
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。
前の記事:小白(続き2)次の記事:小白(続き2)