Comment Passer une Variable de Chaîne dans MultipartEntity?
Je suis de passage 3 images dans MultipartEntity
. Cela fonctionne bien, mais je ne sais pas comment faire pour passer un String
valeur dans MultipartEntity
. Voici mon code:
public void executeMultipartPost(Bitmap bm, int i) throws Exception {
try {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
bm.compress(CompressFormat.JPEG, 75, bos);
byte[] data = bos.toByteArray();
HttpClient httpClient = new DefaultHttpClient();
HttpPost postRequest = new HttpPost("http://www.3dsoles.com/droidapp/index.php");
ByteArrayBody bab = new ByteArrayBody(data, "image" + i + ".jpg");
//File file= new File("/mnt/sdcard/forest.png");
//FileBody bin = new FileBody(file);
MultipartEntity reqEntity = new MultipartEntity(
HttpMultipartMode.BROWSER_COMPATIBLE);
reqEntity.addPart("file", bab);
//reqEntity.addPart("userID", Constants.mUserImei);
reqEntity.addPart("photoCaption", new StringBody("sfsdfsdf"));
postRequest.setEntity(reqEntity);
HttpResponse response = httpClient.execute(postRequest);
BufferedReader reader = new BufferedReader(new InputStreamReader(
response.getEntity().getContent(), "UTF-8"));
String sResponse;
StringBuilder s = new StringBuilder();
while ((sResponse = reader.readLine()) != null) {
s = s.append(sResponse);
}
System.out.println("Response: " + s);
} catch (Exception e) {
BugSenseHandler.log("Uploading File", e);
}
}
vous pouvez m'aider @Dipak
OriginalL'auteur Dipak Keshariya | 2012-04-02
Vous devez vous connecter pour publier un commentaire.
Voir ce lien pour supplémentaire fichiers jar vous devez ajouter..
OriginalL'auteur 5hssba