开发者

Image not found exception while posting to twitpic using httpclient

开发者 https://www.devze.com 2022-12-25 03:08 出处:网络
I am using commons-httpclient-3.1 jar file to Post multipart file to twitpic , iam getting Image not found exception

I am using commons-httpclient-3.1 jar file to Post multipart file to twitpic , iam getting Image not found exception here is my code 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.getP开发者_如何学运维arams())); 
 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);

Any suggestion ,why i am getting this error and why i cannot post images? thanks ganesh

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号