Browse Source

Merge branch 'master' of
http://114.215.100.48:3000/ipu/android-share.git

Conflicts:
display-server/web/res/js/mobile/expand-mobile.js

huangbo 9 years ago
parent
commit
41d19b8de5

+ 1 - 0
display-server/etc/server-page.xml

@ -22,6 +22,7 @@
22 22
	<action name="UI-CustomWindow" template="template/webapp/plugin/UI-CustomWindow.html"></action>
23 23
	<action name="UI-SlidingMenu" template="template/webapp/plugin/UI-SlidingMenu.html"></action>
24 24
	<action name="FileUpload" template="template/webapp/plugin/FileUpload.html"></action>
25
	<action name="RecordVideo" template="template/webapp/plugin/Video.html"></action>
25 26
	<!-- Web Component Demo-->
26 27
	<action name="WmTab" template="template/webapp/tag/WmTab.html"></action>
27 28
	<action name="WmTabbar" template="template/webapp/tag/WmTabbar.html"></action>

+ 0 - 76
display-server/src/com/ai/server/bean/FileUpDownload.java

@ -108,80 +108,4 @@ public class FileUpDownload extends DisplayBean {
108 108
        }
109 109
        return null;
110 110
	}
111
	/**
112
	 * 文件下载
113
	 * @param param
114
	 * @return
115
	 * @throws Exception
116
	 */
117
	public IData download(IData param) throws Exception{
118
		HttpServletRequest request = ServletManager.getRequest();
119
		//获取文件需要上传到的路径
120
		String appPath = ApplicationPath.getFilePath(request);
121
		String path = appPath + File.separator + "upload" + File.separator + "Steven";
122
		File file = new File(path);
123
		if(! file.exists() && ! file.mkdirs()){
124
			throw new RuntimeException("生成用户上传文件夹失败,无法进行上传操作!");
125
		}
126
		
127
		//获得磁盘文件条目工厂
128
		DiskFileItemFactory factory = new DiskFileItemFactory();
129
       //如果没以下两行设置的话,上传大的文件会占用很多内存
130
       //设置暂时存放的存储室,这个存储室可以和最终存储文件的目录不同
131
       /**
132
        * 原理它是先存到暂时存储室,然后在真正写到对应目录的硬盘上
133
        * 按理来说当上传一个文件时,其实是上传了两份,第一个是以.tem格式的
134
        * 然后再将其真正写到对应目录的硬盘上
135
        */
136
        factory.setRepository(file);
137
        //设置缓存的大小,当上传文件的容量超过该缓存时,直接放到暂时存储室
138
        factory.setSizeThreshold(1024*1024);
139
        //文件上传处理
140
        ServletFileUpload upload = new ServletFileUpload(factory);
141
        
142
        try {
143
	        if (! ServletFileUpload.isMultipartContent(request)) {
144
	    		System.out.println("{'result': false, 'error': 网络异常,请重新上传!}");
145
	    	    return null;
146
	        }
147
	        List<?> fileList = upload.parseRequest(request);
148
	        
149
            for(int i = 0; i < fileList.size(); i++){
150
            	
151
            	FileItem item = (FileItem)fileList.get(i);
152
                //获取表单的属性名字
153
                String name = item.getFieldName();
154
                /**以下三步,主要获取上传文件的名字*/
155
                //获取路径名
156
                String value = item.getName();
157
                //索引到最后一个反斜杠
158
                int start = value.lastIndexOf("\\");
159
                //截取 上传文件的 字符串名字,加1是 去掉反斜杠
160
                String filename = value.substring(start + 1);
161
                request.setAttribute(name, filename);
162
                
163
                //写到磁盘上
164
                OutputStream out = new FileOutputStream(new File(path,filename));
165
                InputStream in = item.getInputStream();
166
                
167
                int length = 0;
168
                byte[] buf = new byte[1024];
169
                
170
                System.out.println("获取上传文件的总共的容量:" + item.getSize());
171
                //in.read(BUF)每次读到的数据存放在BUF数组中
172
                while((length = in.read(buf) ) != -1) {
173
                    //在BUF数组中取出数据写到(输出流)磁盘上
174
                    out.write(buf, 0, length);
175
                }
176
                in.close();
177
                out.close();
178
            }
179
        } catch (FileUploadException e) {
180
            e.printStackTrace();
181
            
182
        }catch (Exception e) {
183
            e.printStackTrace();
184
        }
185
        return null;
186
	}
187 111
}

+ 15 - 3
display-server/web/biz/js/plugin/fileupload.js

@ -1,12 +1,24 @@
1 1
require(["domReady!","wadeMobile", "util"], function(doc,WadeMobile) {
2
	//建表
3
	$("#location").tap(function() {
2
	//上传
3
	$("#upload").tap(function() {
4
		//文件上传可以下载多个文件
4 5
		var uploadFiles = new Array();
5 6
//		uploadFiles.push('/Users/kevin/Downloads/cat.png');
6 7
		uploadFiles.push('/Users/kevin/Downloads/cat.txt');
7 8
		
8 9
		WadeMobile.uploadFile(uploadFiles, function(){
9
//			alert("上传成功!");
10
			
11
		});
12
	});
13
	
14
	//下载
15
	$("#download").tap(function() {
16
		//文件下载可以下载多个文件
17
		var uploadFiles = new Array();
18
		uploadFiles.push('http://127.0.0.1:9001/display/upload/default/20151013151525.png');//下载文件地址
19
		
20
		WadeMobile.downloadFile(uploadFiles, function(){
21
			
10 22
		});
11 23
	});
12 24
});

+ 10 - 0
display-server/web/biz/js/plugin/video.js

@ -0,0 +1,10 @@
1
require(["domReady!","wadeMobile", "util"], function(doc,WadeMobile) {
2
	//建表
3
	$("#location").tap(function() {
4
		var uploadFiles = new Array();
5
//		uploadFiles.push('/Users/kevin/Downloads/cat.png');
6
		uploadFiles.push('/Users/kevin/Downloads/cat.txt');
7
		
8
		WadeMobile.recordVideo("1", "30");
9
	});
10
});

+ 9 - 8
display-server/web/res/js/mobile/expand-mobile.js

@ -219,14 +219,15 @@ define(["require"],function(require) {
219 219
			},uploadFile:function(filePath,callback,err){
220 220
				storageCallback("uploadFile",callback);
221 221
				execute("uploadFile",[filePath],err);	
222
			},recordVideo:function(callback,timeLimit,err){
222
			},downloadFile:function(filePath,callback,err){
223
				storageCallback("downloadFile",callback);
224
				execute("downloadFile",[filePath],err);	
225
			},recordVideo:function(callback,compressRatio,timeLimit,err){
223 226
				storageCallback("recordVideo",callback);
224
				execute("recordVideo", [timeLimit],err);
225
			},playVideo:function(path,callback,err){
226
				if(callback){
227
					storageCallback("playVideo",callback);
228
				}
229
				execute("playVideo", [path],err)
227
				execute("recordVideo",[compressRatio,timeLimit],err);	
228
			},playVideo:function(callback,videoPath,err){
229
				storageCallback("playVideo",callback);
230
				execute("playVideo",[videoPath],err);	
230 231
			}
231 232
		};
232 233
	})();
@ -248,4 +249,4 @@ define(["require"],function(require) {
248 249
	}
249 250
	
250 251
	return ExpandMobile;
251
});
252
});

+ 4 - 0
display-server/web/template/webapp/PluginIndex.html

@ -43,4 +43,8 @@
43 43
		<div class="pic"><span class="e_ico-storage"></span></div>
44 44
		<div class="text">文件上传</div>
45 45
	</li>
46
	<li action="RecordVideo">
47
		<div class="pic"><span class="e_ico-storage"></span></div>
48
		<div class="text">视频录制</div>
49
	</li>
46 50
</ul>

+ 20 - 3
display-server/web/template/webapp/plugin/FileUpload.html

@ -21,21 +21,38 @@
21 21

22 22
<div class="m_content m_content-nofooter" id="content" >
23 23
<div>
24
	<div class="c_title">文件位置</div>
24
	<div class="c_title">文件上传</div>
25 25
	<div class="c_list">
26 26
		<ul>
27 27
			<li>
28 28
				<div class="content">
29 29
					<div class="main">
30 30
						<div class="title">文件路径</div>
31
						<div class="info" id="fileLocation">请选择上传文件路径</div>
31
						<div class="info" id="fileUpload">请选择上传文件路径</div>
32 32
					</div>
33
					<div class="fn fn-2" id="location">文件路径</div>
33
					<div class="fn fn-2" id="upload">文件上传</div>
34 34
				</div>
35 35
			</li>
36 36
		</ul>
37 37
	</div>
38 38
</div>
39
<div>
40
	<div class="c_title">文件下载</div>
41
	<div class="c_list">
42
		<ul>
43
			<li>
44
				<div class="content">
45
					<div class="main">
46
						<div class="title">文件路径</div>
47
						<div class="info" id="fileDownload">请选择下载文件路径</div>
48
					</div>
49
					<div class="fn fn-2" id="download">文件下载</div>
50
				</div>
51
			</li>
52
		</ul>
53
	</div>
54
</div>
55

39 56
</div>
40 57
</body>
41 58
</html>

+ 41 - 0
display-server/web/template/webapp/plugin/Video.html

@ -0,0 +1,41 @@
1
<!DOCTYPE HTML>
2
<html class="s_bs">
3
<head>
4
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5
	<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1" />
6
	<title>视频</title>
7
	{%>template/common/Head.html%}
8
	<script type="text/javascript" src="biz/js/plugin/video.js"></script>
9
	<link href="biz/css/project.css" rel="stylesheet" type="text/css" />
10
</head>
11
<body>
12

13
<div class="c_navBar">
14
	<div class="left">
15
		<div class="back">
16
			<span class="e_ico-back"></span>
17
			<span class="text">文件上传</span>
18
		</div>
19
	</div>
20
</div>
21

22
<div class="m_content m_content-nofooter" id="content" >
23
<div>
24
	<div class="c_title">视频</div>
25
	<div class="c_list">
26
		<ul>
27
			<li>
28
				<div class="content">
29
					<div class="main">
30
						<div class="title">视频录制</div>
31
						<div class="info" id="fileLocation">视频录制</div>
32
					</div>
33
					<div class="fn fn-2" id="location">视频录制</div>
34
				</div>
35
			</li>
36
		</ul>
37
	</div>
38
</div>
39
</div>
40
</body>
41
</html>

BIN
display-server/web/upload/default/20151013151525.png