Do android eu mando via post.
String[] result = new String[2];
try {
File file = new File(caminhoImagem);
if (file.exists()) {
HttpPost httpPost = new HttpPost(new URI(URL_WS + url));
FileBody bin = new FileBody(file);
MultipartEntity reqEntity = new MultipartEntity(
HttpMultipartMode.BROWSER_COMPATIBLE);
reqEntity.addPart("file", bin);
httpPost.setEntity(reqEntity);
HttpResponse response;
response = HttpClientSingleton.getHttpClientInstace().execute(
httpPost);
HttpEntity entity = response.getEntity();
if (entity != null) {
result[0] = String.valueOf(response.getStatusLine()
.getStatusCode());
InputStream instream = entity.getContent();
result[1] = toString(instream);
instream.close();
Log.d("post", "Result from post JsonPost : " + result[0]
+ " : " + result[1]);
}
} else {
result[0] = "200";
result[1] = caminhoImagem + " não encontrado.";
}
} catch (Exception e) {
Log.e("NGVL", "Falha ao acessar Web service", e);
result[0] = "0";
result[1] = "Falha de rede!";
}
return result;
Escrevi parte disso agora, então pode ter alguns erros.
2014-07-11 9:42 GMT-04:00 Lucas Couto <lucasarcouto1@gmail.com>:
Usando a classe Base64, do proprio android, se eu usar o método para encodar os bytes da minha imagem direto pra string, dá o seguinte erro no meu DataOuputStream:java.io.UTFDataFormatException: String more than 65535 UTF bytes long
E se eu mandar direto os bytes, o json envia só o endereço de memória.--
You received this message because you are subscribed to the Google Groups "Android Brasil - Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to androidbrasil-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Henrique Nogueira de Melo
Analista e Arquiteto de Software
Analista e Arquiteto de Software
You received this message because you are subscribed to the Google Groups "Android Brasil - Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to androidbrasil-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.






0 comentários:
Postar um comentário