【发布时间】:2012-01-20 07:20:44
【问题描述】:
我正在使用 MIME multipart 将图像上传到服务器。有时图像会失真。如何解决这个问题? 注意:失真意味着丢失了一些像素。 我正在使用以下代码进行上传:
File file = new File(filePath[0]);
HttpClient httpClient = new DefaultHttpClient();
HttpContext localContext = new BasicHttpContext();
HttpPost httpPost = new HttpPost("serverurl");
MultipartEntity entity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
entity.addPart("Content-Type",new StringBody("multipart/form-data;charset=utf-8"));
entity.addPart("Content-Length", new StringBody(String.valueOf(file.length())));
entity.addPart("UploadContentPostD", new FileBody(file));
entity.addPart("DocumentName", new StringBody(file.getName()));
httpPost.setEntity(entity);
HttpResponse response = httpClient.execute(httpPost,localContext);
BufferedReader reader = new BufferedReader(new InputStreamReader(response.getEntity().getContent(), "UTF-8"));
扭曲的图像是:
【问题讨论】:
-
请解释一下您所说的失真是什么意思?坏像素/纵横比改变/像素损坏?
-
像素丢失,因此图像看起来像是与其他部分重叠
标签: android file-upload mime multipart