サーバーに画像をアップロードしようとしています。そのために、apache-mime4j、http client、httpcore、httpmime などの jar ファイルを追加しました。
そして、私のコードは次のとおりです..
HttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(url);
MultipartEntity multiPart = new MultipartEntity();
multiPart.addPart("my_picture", new FileBody(new File(imagePath.toString())));
httpPost.setEntity(multiPart);
HttpResponse res = httpClient.execute(httpPost);
BufferedReader reader = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
String json = reader.readLine();
JSONTokener tokener = new JSONTokener(json);
JSONObject object = (JSONObject) new JSONTokener(json).nextValue();
JSONArray data = object.getJSONArray("data");
System.out.println("posted finalResult"+data);
if (responseEntity != null) {
responseEntity.consumeContent();
}
httpclient.getConnectionManager().shutdown();
問題は、行でエラーが発生していることです
multiPart.addPart("my_picture", new FileBody(new File(imagePath.toString())));
そして、そのエラーをクリックすると、「ビルドパスの構成」が表示されます。
誰でも私のコードで何が間違っているのか教えてください。
事前にサンクス。