Просмотр исходного кода

提交内容:上传文件bug修改

chengwb3 лет назад: 9
Родитель
Сommit
067ba046b2

+ 2 - 2
display-client/assets/display-client/res/js/mobile/expand-mobile.js

@ -25,10 +25,10 @@ define(["require"],function(require) {
25 25
				execute("getDate", [date,format],err);
26 26
			},getContactsView:function(callback,data,setting,err){
27 27
				if(data==undefined){
28
					data = new DataMap();
28
					data = new Wade.DataMap();
29 29
				}
30 30
				if(setting==undefined){
31
					setting = new DataMap();
31
					setting = new Wade.DataMap();
32 32
				}
33 33
				storageCallback("getContactsView",callback);
34 34
				execute("getContactsView", [data.toString(),setting.toString()],err);

+ 10 - 5
display-server/src/com/ai/server/bean/FileUpDownload.java

@ -18,6 +18,7 @@ import org.apache.commons.fileupload.servlet.ServletFileUpload;
18 18
import com.ai.server.core.bean.DisplayBean;
19 19
import com.ai.server.util.ApplicationPath;
20 20
import com.ailk.common.data.IData;
21
import com.ailk.common.data.impl.DataMap;
21 22
import com.ailk.mobile.servlet.ServletManager;
22 23

23 24
/**
@ -35,11 +36,14 @@ public class FileUpDownload extends DisplayBean {
35 36
	 * @throws Exception
36 37
	 */
37 38
	public IData upload(IData param) throws Exception{
39
	    IData result = new DataMap();
38 40
		HttpServletRequest request = ServletManager.getRequest();
41
		request.setCharacterEncoding("UTF-8");
39 42
		//获取文件需要上传到的路径
40 43
		String path = ApplicationPath.getFilePath(request) + "upload" + File.separator;
41 44
		//获取临时目录,文件保存目录
42
		String tempPath = path + "temp", savePath = null;
45
		String tempPath = path + "temp";
46
		String savePath = null;
43 47
		
44 48
		File file = new File(tempPath);
45 49
		if(! file.exists() && ! file.mkdirs()){
@ -72,9 +76,9 @@ public class FileUpDownload extends DisplayBean {
72 76
                 	String value = item.getString();
73 77
                    request.setAttribute(name, value);
74 78
                    //获取用户保存目录
75
                    if(savePath == null)
76
                    	savePath = "USER_NAME".equals(name) ? path + value : tempPath;
77
                 	 
79
                    if(savePath == null){
80
                        savePath = "USER_NAME".equals(name) ? path + value : tempPath;
81
                    }
78 82
                }else{
79 83
                	//获取路径名
80 84
	             	String value = item.getName();
@ -106,6 +110,7 @@ public class FileUpDownload extends DisplayBean {
106 110
	                out.close();
107 111
	                
108 112
	                log.debug("获取上传文件的总共的容量:" + item.getSize());
113
	                result.put("size", item.getSize());
109 114
               }
110 115
           }
111 116
       } catch (FileUploadException e) {
@ -114,7 +119,7 @@ public class FileUpDownload extends DisplayBean {
114 119
       }catch (Exception e) {
115 120
           e.printStackTrace();
116 121
       }
117
       return null;
122
       return result;
118 123
	}
119 124
	/************************************************************************************
120 125
	 * 文件下载;

+ 3 - 1
display-server/web/biz/js/plugin/uploaddownload.js

@ -4,8 +4,10 @@ require(["domReady!","wadeMobile", "util"], function(doc,WadeMobile) {
4 4
		/*单文件上传*/
5 5
		WadeMobile.getPicture(function(path){
6 6
			console.log(path);
7
			$("#fileUpload").html(path);
7 8
			WadeMobile.uploadWithServlet(path, "FileUpDownload.upload", null, function(result){
8
				alert(result)
9
				var data = new Wade.DataMap(result);
10
				alert("上传文件的大小:" + data.get("size") + "字节.");
9 11
			});
10 12
		});
11 13
		

+ 2 - 2
display-server/web/res/js/mobile/expand-mobile.js

@ -25,10 +25,10 @@ define(["require"],function(require) {
25 25
				execute("getDate", [date,format],err);
26 26
			},getContactsView:function(callback,data,setting,err){
27 27
				if(data==undefined){
28
					data = new DataMap();
28
					data = new Wade.DataMap();
29 29
				}
30 30
				if(setting==undefined){
31
					setting = new DataMap();
31
					setting = new Wade.DataMap();
32 32
				}
33 33
				storageCallback("getContactsView",callback);
34 34
				execute("getContactsView", [data.toString(),setting.toString()],err);

+ 11 - 1
wade-mobile-func/src/com/wade/mobile/func/MobileNetWork.java

@ -19,6 +19,7 @@ import com.ailk.common.data.impl.DataMap;
19 19
import com.litesuits.http.LiteHttpClient;
20 20
import com.litesuits.http.request.Request;
21 21
import com.litesuits.http.response.Response;
22
import com.mashape.unirest.http.Unirest;
22 23
import com.wade.mobile.app.MobileAppInfo;
23 24
import com.wade.mobile.common.MobileThread;
24 25
import com.wade.mobile.common.bluetooth.activity.ShareByBluetoothActivity;
@ -333,7 +334,16 @@ public class MobileNetWork extends Plugin {
333 334
						}
334 335
						filePostData.put("FILE"+i, filePath);//再装载文件
335 336
					}
336
					result = UnirestUtil.uploadByPost(MobileConfig.getInstance().getRequestUrl(), filePostData);
337
					//result = UnirestUtil.uploadByPost(MobileConfig.getInstance().getRequestUrl(), filePostData);
338
                    String requestUrl = MobileConfig.getInstance()
339
                            .getRequestUrl();
340
                    String url = requestUrl + "?action=" + dataAction;
341
                    result = Unirest.post(url)
342
                            .header("accept", "application/json")
343
                            .fields(filePostData)
344
                            .field("file", new File(filePath)).asString()
345
                            .getBody();
346

337 347
					if (ServerDataConfig.isEncrypt(dataAction)) {
338 348
						result = MobileSecurity.responseDecrypt(result);
339 349
					}

BIN
wade-mobile-lib/libs/pinyin4j-2.5.0.jar


BIN
wade-mobile-library/common/commons-io-2.4.jar