1

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

ganesh
  • 1,247
  • 6
  • 24
  • 46
  • Presumably you don't have a file at the path "photo" -- but you really ought to post the actual traceback, as well as why you decided to use an older version of HTTPClient bundled in an external jar rather than the org.apache.http libraries that come with Android (HTTPComponents Client v4). – Yoni Samlan Mar 25 '10 at 18:20
  • thanks yoni ,i missed that ,it should be "media" instead of "photo".i will take up your suggestion to use Android libs – ganesh Mar 26 '10 at 04:15

0 Answers0