我正在使用commons-httpclient-3.1 jar文件将多部分文件发布到twitpic,我发现图像未找到异常 这是我的代码 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);
任何建议,为什么我收到此错误以及为什么我无法发布图片? 谢谢ganesh