Byr*_*yrd 6 java apache android mime ruby-on-rails
我正在尝试发送MultipartEntityBuilder到我的Rails服务器.但是,当我尝试构建它时崩溃并给我错误
03-25 09:44:50.001 W/System.err? java.util.concurrent.ExecutionException: java.lang.NoSuchMethodError: No static method create(Ljava/lang/String;[Lorg/apache/http/NameValuePair;)Lorg/apache/http/entity/ContentType; in class Lorg/apache/http/entity/ContentType; or its super classes (declaration of 'org.apache.http.entity.ContentType
HttpPost httpost = new HttpPost(url);
MultipartEntityBuilder entity = new MultipartEntityBuilder.create();
entity.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
for(int index=0; index < nameValuePairs.size(); index++) {
ContentBody cb;
if(nameValuePairs.get(index).getName().equalsIgnoreCase("File")) {
File file = new File(nameValuePairs.get(index).getValue());
FileBody isb = new FileBody(file);
entity.addPart(nameValuePairs.get(index).getName(), isb);
} else {
// Normal string data
cb = new StringBody(nameValuePairs.get(index).getValue(),ContentType.TEXT_PLAIN);
entity.addPart(nameValuePairs.get(index).getName(),cb);
}
}
return entity.build();
Run Code Online (Sandbox Code Playgroud)
这是我正在使用的代码,我仍然在构建MultipartEntity时遇到错误,它会说错误.
Mat*_*eus 21
尝试使用httpmime版本4.3.6
我尝试使用4.4+但总是同样的问题.
| 归档时间: |
|
| 查看次数: |
3037 次 |
| 最近记录: |