0
上のAndroid携帯電話から受信した私はそれをhanldesサーバーには、Androidの携帯電話から画像を送信していますが、今私は、サーバーにがサーバー
を画像を使用する方法について混乱しています画像を送信し、Androidの携帯電話のための私のコードは、サーバーで画像を処理し、今私はDISへのバイト配列を使用してくださいどのようにこの
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();
のようなものです
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);
と私のコードです...私はこれがあなたのために働くべきだと思うなど、サーバー側の
http://www.mkyong.com/java/how-to-convert-byte-to-bufferedimage-in-java/
を
質問は何ですか? –
サーブレットで電話機から受信したデータを画像として使用して編集する方法を教えてください。受け取った画像はアイテム変数にあります – SaNmm
編集したらどういう意味ですか?トリミングしますか?、サイズを変更しますか?操作する? –