我正在使用 commons-httpclient-3.1 jar 文件将多部分文件发布到 twitpic ,我得到 Image not found 异常这里是我的代码 HttpClient client = new HttpClient(); client.getHttpConnectionManager().getParams().setConnectionTimeout(100000);
PostMethod method = new PostMethod("http://twitpic.com/api/uploadAndPost");
FilePart photo = new FilePart("photo", new ByteArrayPartSource("photo", b));
photo.setContentType("image/jpeg");
photo.setCharSet(null);
Part[] parts = { new StringPart("service", "Android mobile"),
new StringPart("username", "xxxxxx"),
new StringPart("password", "xxxxxx"),
new StringPart("message", "Test message"),
photo };
try {
method.setRequestEntity(new MultipartRequestEntity(parts, method.getParams()));
client.executeMethod(method);
responseString = method.getResponseBodyAsString();
method.releaseConnection();
} catch (HttpException e) {
Log.v("e",e.toString());
e.printStackTrace();
} catch (IOException e) {
Log.v("e2",e.toString());
e.printStackTrace();
}
finally {
method.releaseConnection();
}
Log.v( "Response status: " , responseString);
任何建议,为什么我会收到这个错误以及为什么我不能发布图片?谢谢甘尼什