对于发布到Web服务器的Android的COM preSS数据 [英] Android Compress data for posting to web server
问题描述
我仍然在Android的初学者。我使用目前的HTTPClient发送通过Android应用大量数据(JSON)到Web服务器。我发现, HttpURLConnection类支持DECOM pression的请求,但有任何支持或者说我可以上传一个COM preSS / gzip压缩JSON到Web服务器的任何方式?
I am still a beginner in Android. I am currently sending large amount of data(json) from the android app to web server using HTTPClient. I found that HttpURLConnection supports decompression for request but is there any support or any way that I can upload a compress/gzipped json to the web server?
是实现这一目标的唯一途径手动gzip压缩的JSON字符串,并把gzip压缩串入到帖子?
Is the only way to achieve this is to manually gzip the json string and put the gzipped string into in to the post?
推荐答案
您可以在HTTP头添加GZIP COM pression。
You can add GZIP compression in your HTTP header.
HttpUriRequest request = new HttpGet(url);
request.addHeader("Content-Encoding", "gzip");
// ...
httpClient.execute(request);
您可以检查<一href=\"http://stackoverflow.com/questions/1573391/android-http-communication-should-use-accept-encoding-gzip/1576513#1576513\">this链接以获取更多信息。
You can check this link for more information
这篇关于对于发布到Web服务器的Android的COM preSS数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!