0
我從Android手機發送圖像到hanldes在服務器上的圖像,但是現在我如何在服務器中使用的圖像混亂如何顯示或使用來自Android手機收到的服務器
我的Android手機,它發送的圖像代碼是
Log.i("sAMPLE","Info:");
//String postURL = HOST_SERVER_URL + HOST_PHOTO_UPLOAD_URI;
String postURL ="http://10.0.2.2:8080/SimpleServlet/simple-servlet";//server URL
HttpClient httpClient = new DefaultHttpClient();
HttpPost postRequest = new HttpPost(postURL);
ByteArrayBody bab = new ByteArrayBody(imageBytes, "file_name_ignored");
MultipartEntity reqEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
reqEntity.addPart("source", bab);
postRequest.setEntity(reqEntity);
HttpResponse response = httpClient.execute(postRequest);
和我的代碼負責處理圖像中的服務器是這樣
protected void doPost(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
boolean isMultipart = ServletFileUpload.isMultipartContent(req);
System.out.println("Before Mutlipart");
if(!isMultipart)
throw new ServletException("upload using multipart");
ServletFileUpload upload = new ServletFileUpload(fif);
upload.setSizeMax(1024 * 1024 * 10 /* 10 mb */);
List<FileItem> items;
try {
items = upload.parseRequest(req);
//}// catch (FileUploadException e) {
// throw new ServletException(e);
} catch (FileUploadException e) {
// TODO Auto-generated catch block
throw new ServletException(e);
}
if(items == null || items.size() == 0)
throw new ServletException("No items uploaded");
FileItem item = items.get(0);
//BufferedImage Img=item.getString();
System.out.println(item.getContentType());
byte[]data=item.get();
現在我該怎樣使用字節數組DIS
在服務器端播放服務器上的圖像或使用其他一些東西像字符串,其他圖像等
什麼問題? –
我應該如何使用從servlet上的手機接收的數據作爲圖像,以便我可以編輯它..我收到的圖像是在項目變量中 – SaNmm
你是什麼意思編輯它?你想裁剪?調整大小?操作? –