Estou tentando enviar 18 imagens e o tamanho é 1mb no máximo.
2013/9/29 Bruno Albuquerque <bruno.albuquerque@gmail.com>
Mas quantas imagens está transferindo. Com esse link e com esse tamanho de imagem você conseguiria transferir um pouco mais de 1 imagem por segundo. Mas isso é em condições ideais onde você realmente consegue os 15 mbit/s (aproximadamente 1,78 M/s) entre o seu dispositivo e o servidor rodando o seu webservice.O primeiro passo é determinar qual o seu gargalo real. O segundo é tentar encontrar maneiras de se eliminar esse gargalo.--On Thu, Sep 26, 2013 at 6:38 PM, Diego Lopes Marques da Silva <diego.lopes@dce.ufpb.br> wrote:
Estou utilizando um wifi d 15mb e a imagem maior é de 1.1mb2013/9/26 Bruno Albuquerque <bruno.albuquerque@gmail.com>
Fora usar uma conexão mais rápida ou imagens menores?--On Thu, Sep 26, 2013 at 6:17 PM, Diego Lopes Marques da Silva <diego.lopes@dce.ufpb.br> wrote:
--AndroidPessoal,Estou enviando uma lista de imagens para um webservice e está funcionando normalmente. O problema é que ele está demorando demais. Alguém sabe alguma outra alternativa para diminuir esse tempo?
Obrigado
private List getPhotosFromSDCard(String dir){
File dir = new File(Environment.getExternalStorageDirectory().getPath() + dir");
if(dir.exists() && dir.isDirectory()){
File[] files = dir.listFiles();
if(files.length!=0){
filesPath = new LinkedList();
for(File f: files){
filesPath.add(f.getAbsolutePath());
}
}
}
return filesPath;
}
private class UploadPhotosAsyncTask extends AsyncTask<List, Void, String> {
private List files;
@Override
protected String doInBackground(List... arg0) {
String res = null;
try {
files = arg0[0];
HttpPost httppost = new HttpPost(Constants.URL_UPLOAD);
MultipartEntity multipartEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
for(int i=0; i<files.size(); i++){
try {
if ((files.get(i).toString() != null) && (!files.get(i).toString().equals(""))) {
InputStreamBody foto = new InputStreamBody( new FileInputStream( new File(files.get(i).toString()) ), files.get(i).toString() );
multipartEntity.addPart("foto"+i, foto);
}
} catch (FileNotFoundException e) {
}
}
httppost.setEntity(multipartEntity);
HttpParams params = new BasicHttpParams();
params.setParameter(CoreProtocolPNames.PROTOCOL_VERSION, HttpVersion.HTTP_1_1);
HttpClient httpClient = new DefaultHttpClient(params);
ResponseHandler<String> responseHandler = new BasicResponseHandler();
res = httpClient.execute(httppost, responseHandler);
} catch (SocketException e) {
Log.e(Constants.TAG, e.getMessage(), e);
} catch (Throwable e) {
Log.e(Constants.TAG, e.getMessage(), e);
}
return res;
}
Webservice
private void uploadFile(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
for(Part part : request.getParts()) {
String name = part.getName();
InputStream is = request.getPart(name).getInputStream();
String fileName = getUploadedFileName(part);
DbUtil.insertImage(is, fileName, name);
}
}
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/groups/opt_out.
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/groups/opt_out.
--
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/groups/opt_out.
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/groups/opt_out.
--
Diego Lopes Marques
MSc. Candidate in Computer Science at PPgSC - UFRN
MSc. Candidate in Computer Science at PPgSC - UFRN
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/groups/opt_out.
0 comentários:
Postar um comentário