views:

139

answers:

0

Hi group, 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.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);

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