lines-num-old">
String filePath = null;
File file;
for(int i=0;i<filePaths.length();i++){
filePath = filePaths.getString(i);
file = new File(filePath);
if(!file.exists()){
Utility.error(Messages.FILE_NOT_EXIST+":"+filePath);
}
filePostData.put("FILE"+i, filePath);//再装载文件
}
result = UnirestUtil.uploadByPost(MobileConfig.getInstance().getRequestUrl(), filePostData);
}catch(Exception e){
MobileNetWork.this.error(e.getMessage());// 报错回调
}
return result;
}
@Override
protected void onPostExecute(String result) {
// TODO Auto-generated method stub
super.onPostExecute(result);
if (result != null) {
MobileNetWork.this.callback(result);// 正常回调
}
}
}.execute();
}
public void downloadWithServlet(JSONArray param) throws Exception {
String savePath = param.getString(0);
String dataAction = param.getString(1);
IData dataParam = param.getString(2)==null?new DataMap():new DataMap(param.getString(2));
downloadWithServlet(savePath, dataAction, dataParam);
}
public void downloadWithServlet(final String savePath, String dataAction, IData dataParam) throws Exception {
// TODO Auto-generated method stub
Map<String, String> tempPostData = transPostData(dataAction, dataParam);
final Map<String, Object> postData = new HashMap<String, Object>();
postData.putAll(tempPostData);
new AsyncTask<String, Integer, String>() {
@Override
protected String doInBackground(String... arg0) {
// TODO Auto-generated method stub
String result = null;
try{
InputStream in = UnirestUtil.downloadByPost(MobileConfig.getInstance().getRequestUrl(), postData);
FileUtil.writeFile(in, savePath);
result = "下载成功";
}catch(Exception e){
MobileNetWork.this.error(savePath + "异常:"+e.getMessage());// 报错回调
}
return result;
}
@Override
protected void onPostExecute(String result) {
// TODO Auto-generated method stub
super.onPostExecute(result);
if (result != null) {
MobileNetWork.this.callback(result);// 正常回调
}
}
}.execute();
}
public void uploadFile(JSONArray param) throws Exception {
|
||
23 | 23 |
|
24 | 24 |
|
25 | 25 |
|
26 |
|
|
27 | 26 |
|
28 | 27 |
|
29 | 28 |
|
|
||
182 | 181 |
|
183 | 182 |
|
184 | 183 |
|
184 |
|
|
185 |
|
|
186 |
|
|
187 |
|
|
188 |
|
|
189 |
|
|
190 |
|
|
191 |
|
|
192 |
|
|
193 |
|
|
194 |
|
|
195 |
|
|
196 |
|
|
197 |
|
|
198 |
|
|
199 |
|
|
200 |
|
|
201 |
|
|
202 |
|
|
203 |
|
|
204 |
|
|
205 |
|
|
206 |
|
|
207 |
|
|
208 |
|
|
209 |
|
|
210 |
|
|
211 |
|
|
212 |
|
|
213 |
|
|
214 |
|
|
215 |
|
|
216 |
|
|
217 |
|
|
218 |
|
|
219 |
|
|
220 |
|
|
221 |
|
|
222 |
|
|
223 |
|
|
224 |
|
|
225 |
|
|
226 |
|
|
227 |
|
|
228 |
|
|
229 |
|
|
230 |
|
|
231 |
|
|
185 | 232 |
|
186 | 233 |
|
187 | 234 |
|
|
||
1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
1 |
|
|
2 |
|
|
3 |
|
|
4 |
|