0
嗨,大家好我想圖像發佈到db.Here我張貼圖像從Android客戶端到DB.Spring MVC REST Web服務是中間層。你請建議我如何將圖像byte []值從Android客戶端發佈到數據庫。預先感謝您的寶貴建議。如何發佈圖像byte []值到數據庫在春天mvc
嗨,大家好我想圖像發佈到db.Here我張貼圖像從Android客戶端到DB.Spring MVC REST Web服務是中間層。你請建議我如何將圖像byte []值從Android客戶端發佈到數據庫。預先感謝您的寶貴建議。如何發佈圖像byte []值到數據庫在春天mvc
可以使用MultipartEntity
public static HttpResponse sendImage(byte[] image) {
HttpResponse responsePOST = null;
try {
HttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost(postURL+"user_profile");
post.setHeader("Accept", "application/json");
ByteArrayBody bab = new ByteArrayBody(image, firstname+".png");
MultipartEntity reqEntity = new MultipartEntity(
HttpMultipartMode.BROWSER_COMPATIBLE);
reqEntity.addPart("user_profile[image_attributes[attachment]]", bab);
post.setEntity(reqEntity);
responsePOST = client.execute(post);
} catch (Exception e) {
e.printStackTrace();
}
return responsePOST;
}
您能否提供我任何教程,Android的.. – Hits
http://stackoverflow.com/questions/19738594/multipartentity-post-android – Sanu
http://chrislee.kr/wp/tag/multipartentity-example-android/ – Sanu