1
WCF 서비스에 이미지를 업로드 할 수있는 Android 프로그램이 있습니다. WCF 서비스는 이미지 이름, 폴더 이름 및 이미지의 base64 인코딩과 함께 JSON 객체를 허용합니다.base64 인코딩 업로드 이미지를 android에서 WCF 서비스로
필자는 서비스 테스트를 위해 바이올린을 사용하여 온라인 서비스에서 이미지를 인코딩하고이를 개체에 넣었습니다. 그런 다음 POST 요청을 작성했습니다. WCF 서비스가 성공적으로 이미지를 업로드했습니다.
하지만 Android HTTP 클라이언트를 사용하고 WCF가 요청을 수락하는 경우에도 이미지를 인식하지 못합니다. 나는이 문제를 이해할 수
try {
HttpPost httpPost=new HttpPost(this.remoteBasePath);
JSONObject obj = new JSONObject();
obj.put(FILE_NAME, fileName);
obj.put(FILE_STREAM,fileStream);
obj.put(FOLDER_NAME, remoteFolder);
httpPost.setHeader("Content-type", "application/json; charset=utf-8");
httpPost.setEntity(new StringEntity(obj.toString()));
httpPost.setHeader(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));
httpResponse=httpClient.execute(httpPost);
if(httpResponse!=null){
TLLog.d(TAG,"StatusCode : "+ httpResponse.getStatusLine().getStatusCode());
if (httpResponse.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
InputStream instream = httpResponse.getEntity().getContent();
BufferedReader r = new BufferedReader(
new InputStreamReader(instream));
StringBuilder total = new StringBuilder();
String line;
while ((line = r.readLine()) != null) {
total.append(line);
}
instream.close();
String result = total.toString();
TLLog.d(TAG,"Image posting result : "+ result);
return true;
}
}
} catch (ClientProtocolException e) {
TLLog.e(TAG, e.getStackTrace().toString());
} catch (IOException e) {
TLLog.e(TAG, e.getStackTrace().toString());
} catch (JSONException e) {
e.printStackTrace();
}
:
여기 내 안드로이드 코드입니다.
문제가 이미지에만있는 경우 JSON 객체에 넣을 때'fileStream'이 이미 잘못되었다고 생각합니다. – Henry
답장을 보내 주셔서 감사합니다. – Sanath