如何上传从Android设备的文件到服务器? [英] how to upload a file to server from android device?

查看:160
本文介绍了如何上传从Android设备的文件到服务器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有必要使用比HTTP POST对小文件以外的其他? (小于1MB)

Is there any need to use something other than a http POST for small files? (<1mb)

使用大文件谁知道现有的lib来处理他们(preferably显示在对话框中的进度条)的

With large files anyone know of an existing lib to handle them (and preferably show a progress bar in a dialog)

推荐答案

我已经包括了Apache的mime4j-0.6和httpmime-4.0.1得到这个功能。有了这些库,你可以创建的multipart / form-data的请求,并与标准的HttpClient给他们了。

I've included apache-mime4j-0.6 and httpmime-4.0.1 to get this functionality. With those libraries you can create multipart/form-data requests and send them off with the standard HttpClient.

//total pseudo-code; class names are right, though
HttpPost post;
MulitpartEntity mpe;
mpe.addPart("file", new InputStreamBody() or new FileBody());
post.setEntity(mpe);
httpClient.execute(post);

这篇关于如何上传从Android设备的文件到服务器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆