解决httpclient上传文件的时候中文文件名乱码的问题

需要做一下设置:

完整代码:
	public static String post(String url,Map paramsMap) throws ClientProtocolException, IOException{
		HttpPost httpPost = new HttpPost(url);
		MultipartEntityBuilder entityBuilder = MultipartEntityBuilder.create();
		entityBuilder.setCharset(Charset.forName("utf-8"));
		entityBuilder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
		ContentType contentType = ContentType.create(HTTP.PLAIN_TEXT_TYPE, HTTP.UTF_8); 
		//填充参数
		Set keySet = paramsMap.keySet();
		for(String key:keySet){
			Object obj = paramsMap.get(key);
			if(obj instanceof File){ //参数是File 类型
				File file = (File) obj;
				entityBuilder.addPart(key, new FileBody(file));
			}else if(obj instanceof String){ //参数是String 类型
				String value = (String) obj;
				entityBuilder.addPart(key, new StringBody(value,contentType));
			}else if(obj instanceof byte[]){
				

你可能感兴趣的:(Android,安卓)