Created
January 6, 2015 09:43
-
-
Save dingbuoyi/19080941784071ab0afa to your computer and use it in GitHub Desktop.
aquery 上传文件
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File dir = Environment.getExternalStorageDirectory();//获取SD卡目录 | |
File file = new File(dir, "girl.jpg");//文件必须存在,自己放个同名的图片过去 | |
AQuery aq = new AQuery(TestActivity.this); | |
String url = APIAgent.URL_SERVER_IMPRESSION_UPLOAD; | |
Map<String, Object> params = new HashMap<String, Object>(); | |
params.put("message", "Message"); | |
params.put("file", file);//可以传二进制数据也可以传文件 | |
AjaxCallback<String> cb = new AjaxCallback<String>() { | |
@Override | |
public void callback(String url, String object, AjaxStatus status) { | |
System.out.println(object); | |
System.out.println(status.getCode()); | |
System.out.println(status.getMessage()); | |
} | |
}; | |
cb.cookie("Cookie", "PHPSESSID=ejfhv338ja3o20jt73rvjgslk2; path=/;REMEMBERME=b63a4e7c0e011a12a76624e7bf3d3a5cde8e5af9; expires=Sat, 07-Mar-2015 09:11:16 GMT; Max-Age=5184000; path=/; httponly");//有的时候需要带上Cookies | |
aq.ajax(url, params, String.class, cb); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment