├── .gitignore
├── .travis.yml
├── AnyUploadClient
├── index.html
└── js
│ ├── anyupload
│ ├── Gruntfile.js
│ ├── css
│ │ └── anyupload.css
│ ├── dist
│ │ ├── anyupload.js
│ │ └── anyupload.min.js
│ ├── images
│ │ ├── ai.png
│ │ ├── all_cancel.png
│ │ ├── cancel.png
│ │ ├── doc.png
│ │ ├── jpg.png
│ │ ├── minimize.png
│ │ ├── pause.png
│ │ ├── pdf.png
│ │ ├── png.png
│ │ ├── ppt.png
│ │ ├── psd.png
│ │ ├── qitageshi.png
│ │ ├── start.png
│ │ ├── txt.png
│ │ └── xls.png
│ ├── package.json
│ └── src
│ │ ├── ByteUtil.js
│ │ ├── FileConfig.js
│ │ ├── FileMediator.js
│ │ ├── FileSystemStatus.js
│ │ ├── NotificationExt.js
│ │ ├── PostfixUtil.js
│ │ ├── UploadEventType.js
│ │ ├── UploadFileObj.js
│ │ └── UploadFileProxy.js
│ └── lib
│ ├── jquery.min.js
│ ├── juggle-all.js
│ ├── juggle-all.min.js
│ ├── juggle-event.js
│ ├── juggle-event.min.js
│ ├── juggle-help.js
│ ├── juggle-help.min.js
│ ├── juggle-http.js
│ ├── juggle-http.min.js
│ ├── juggle-juggler.js
│ ├── juggle-juggler.min.js
│ ├── juggle-mv.js
│ ├── juggle-mv.min.js
│ ├── spark-md5.js
│ └── spark-md5.min.js
├── AnyUploadServer
├── .gitignore
├── WebContent
│ ├── META-INF
│ │ └── MANIFEST.MF
│ └── WEB-INF
│ │ ├── lib
│ │ ├── commons-beanutils-1.9.3.jar
│ │ ├── commons-collections-3.2.2.jar
│ │ ├── commons-fileupload-1.3.2.jar
│ │ ├── commons-io-2.5.jar
│ │ ├── commons-lang-2.6.jar
│ │ ├── commons-logging-1.2.jar
│ │ ├── ezmorph-1.0.6.jar
│ │ ├── httpserver-1.0.0.jar
│ │ ├── javax.servlet-api-3.1.0.jar
│ │ ├── json-lib-2.4-jdk15.jar
│ │ ├── log-1.0.0.jar
│ │ ├── log4j-1.2.17.jar
│ │ ├── protobuf-java-3.1.0.jar
│ │ ├── protobuf-java-format-1.4.jar
│ │ ├── slf4j-api-1.7.22.jar
│ │ └── slf4j-log4j12-1.7.22.jar
│ │ └── web.xml
├── build-Server.xml
├── protobuf
│ ├── ErrorProto.proto
│ ├── UploadFileProto.proto
│ ├── protobuf编译.bat
│ └── protoc.exe
└── src
│ ├── main
│ └── java
│ │ ├── log4j.properties
│ │ └── org
│ │ └── anyupload
│ │ ├── CommonConfig.java
│ │ ├── Expand.java
│ │ ├── FileBase.java
│ │ ├── FileBaseConfig.java
│ │ ├── HOpCode.java
│ │ ├── HttpLog.java
│ │ ├── IUserFileAction.java
│ │ ├── MyAppender.java
│ │ ├── UploadService.java
│ │ ├── UserFile.java
│ │ ├── UserFileAction.java
│ │ └── protobuf
│ │ ├── ErrorProto.java
│ │ └── UploadFileProto.java
│ └── test
│ └── java
│ └── org
│ └── anyupload
│ └── Test.java
├── LICENSE
├── README.md
├── anyupload.png
├── anyuploadflow.png
├── anyuploadflow.pptx
└── build.xml
/.gitignore:
--------------------------------------------------------------------------------
1 | dist
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: java
2 | install: ant
--------------------------------------------------------------------------------
/AnyUploadClient/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
53 |
54 |
55 |
57 |
58 |
59 |
60 |
--------------------------------------------------------------------------------
/AnyUploadClient/js/anyupload/Gruntfile.js:
--------------------------------------------------------------------------------
1 | module.exports = function (grunt) {
2 | // 项目配置
3 | grunt.initConfig({
4 | pkg: grunt.file.readJSON('package.json'),
5 | concat: {
6 | options: {
7 | separator: '\n\r'
8 | },
9 | dist: {
10 | src: [
11 | 'src/ByteUtil.js',
12 | 'src/FileConfig.js',
13 | 'src/NotificationExt.js',
14 | 'src/PostfixUtil.js',
15 | 'src/UploadEventType.js',
16 | 'src/FileSystemStatus.js',
17 | 'src/UploadFileProxy.js',
18 | 'src/UploadFileObj.js',
19 | 'src/FileMediator.js'
20 | ],
21 | dest: 'dist/<%= pkg.name %>.js'
22 | }
23 | },
24 | uglify: {
25 | build: {
26 | src: 'dist/<%= pkg.name %>.js',
27 | dest: 'dist/<%= pkg.name %>.min.js'
28 | }
29 | }
30 | });
31 | grunt.loadNpmTasks('grunt-contrib-uglify');
32 | grunt.loadNpmTasks('grunt-contrib-concat');
33 | // 默认任务
34 | grunt.registerTask('default', ['concat', 'uglify']);
35 | };
--------------------------------------------------------------------------------
/AnyUploadClient/js/anyupload/css/anyupload.css:
--------------------------------------------------------------------------------
1 | table {
2 | border-collapse: collapse;
3 | table-layout: fixed;
4 | }
5 |
6 | body, div, dl, dt, dd, ul, ol, li, h1, h2, h3, h4, h5, h6, pre, code, form, fieldset, legend, textarea, p, blockquote, th, td, input, select, textarea, button, img {
7 | padding: 0;
8 | margin: 0;
9 | font-size: 12px;
10 | line-height: 1;
11 | font-family: "Microsoft YaHei";
12 | font-weight: normal;
13 | font-style: normal;
14 | color: #333;
15 | word-break: break-all
16 | }
17 |
18 | body {
19 | font-family: "Microsoft YaHei";
20 | position: relative;
21 | background: none
22 | }
23 |
24 | body, input, select, textarea, button {
25 | font-size: 12px;
26 | line-height: 1
27 | }
28 |
29 | blockquote:before, blockquote:after, q:before, q:after {
30 | content: '';
31 | content: none
32 | }
33 |
34 | a {
35 | text-decoration: none;
36 | color: #333;
37 | }
38 |
39 | fieldset, img, abbr, acronym {
40 | border: 0 none;
41 | }
42 |
43 | img {
44 | vertical-align: top;
45 | }
46 |
47 | abbr, acronym {
48 | font-variant: normal;
49 | }
50 |
51 | blockquote, q {
52 | quotes: none
53 | }
54 |
55 | dl, ul, ol, menu, li {
56 | list-style: none
57 | }
58 |
59 | input, button, textarea, select, optgroup, option {
60 | font-family: inherit;
61 | font-size: inherit;
62 | font-style: inherit;
63 | font-weight: inherit;
64 | }
65 |
66 | /* 输入控件字体 */
67 | input, select, textarea, button {
68 | vertical-align: middle;
69 | outline: none;
70 | }
71 |
72 | textarea {
73 | resize: none;
74 | overflow: auto;
75 | }
76 |
77 | input[type="button"] {
78 | cursor: pointer;
79 | }
80 |
81 | button {
82 | border: 0 none;
83 | background-color: transparent;
84 | cursor: pointer
85 | }
86 |
87 | input::-moz-focus-inner {
88 | border: 0;
89 | padding: 0;
90 | }
91 |
92 | h1, h2, h3, h4, h5, h6 {
93 | font-size: 100%;
94 | font-weight: normal
95 | }
96 |
97 | table {
98 | table-layout: fixed;
99 | border-collapse: collapse;
100 | }
101 |
102 | a:focus {
103 | outline: none;
104 | }
105 |
106 | input::-ms-clear, input::-ms-reveal {
107 | display: none;
108 | }
109 |
110 | .hide {
111 | display: none;
112 | }
113 |
114 | .pb0 {
115 | padding-bottom: 0 !important;
116 | }
117 |
118 | /* clearfix */
119 | .clearfix {
120 | *zoom: 1;
121 | }
122 |
123 | .clearfix:after {
124 | display: table;
125 | line-height: 0;
126 | content: "";
127 | clear: both;
128 | }
129 |
130 | .clear {
131 | clear: both;
132 | }
133 |
134 | /* public.omission */
135 | .fl {
136 | float: left;
137 | display: inline
138 | }
139 |
140 | .fr {
141 | float: right;
142 | display: inline
143 | }
144 |
145 | /*uploader_list_header*/
146 | .uploader_list_header {
147 | width: 100%;
148 |
149 | left: 0;
150 | top: 0;
151 | background-color: #f5f6f7;
152 | height: 42px;
153 | line-height: 42px;
154 | padding: 0 20px;
155 | box-sizing: border-box;
156 | }
157 |
158 | .uploader_list_header > div {
159 | line-height: 42px;
160 | text-align: center;
161 | }
162 |
163 | .uploader_list_header .file_status {
164 | margin-top: 0;
165 | }
166 |
167 | .uploader_list_header .file_name {
168 | text-align: left;
169 | }
170 |
171 | .uploadBoxT {
172 | padding: 0 20px;
173 | height: 46px;
174 | line-height: 46px;
175 | background-color: #fff;
176 | }
177 |
178 | .uploadBoxT p {
179 | line-height: 46px;
180 | font-size: 16px;
181 | }
182 |
183 | .uploadBoxT i {
184 | width: 24px;
185 | height: 24px;
186 | cursor: pointer;
187 | display: inline-block;
188 | vertical-align: top;
189 | margin: 13px 0 0 14px;
190 | }
191 |
192 | .uploadBoxT i:hover {
193 | opacity: .7;
194 | filter: alpha(opacity=70);
195 | }
196 |
197 | .all_cancel {
198 | background: url("../images/all_cancel.png") no-repeat center center;
199 | }
200 |
201 | .minimize {
202 | background: url("../images/minimize.png") no-repeat center center;
203 | }
204 |
205 | .uploadBoxB ul {
206 | overflow: auto;
207 | margin-top: 42px;
208 | }
209 |
210 | .uploadBoxB ul li {
211 | height: 56px;
212 | line-height: 56px;
213 | padding: 0 20px;
214 | box-sizing: border-box;
215 | font-size: 14px;
216 | overflow: hidden;
217 | }
218 |
219 | /*文件名*/
220 | .file_name {
221 | overflow: hidden;
222 | text-overflow: ellipsis;
223 | white-space: nowrap;
224 | display: inline-block;
225 | position: relative;
226 | width: 30%;
227 | float: left;
228 | font-size: 14px;
229 | }
230 |
231 | .file_icon {
232 | width: 26px;
233 | height: 32px;
234 | background: url("../images/qitageshi.png") no-repeat center center;
235 | position: absolute;
236 | top: 12px;
237 | left: 0;
238 | font-size: 14px;
239 | }
240 |
241 | .fileicon_ai {
242 | background-image: url("../images/ai.png");
243 | }
244 |
245 | .fileicon_doc {
246 | background-image: url("../images/doc.png");
247 | }
248 |
249 | .fileicon_jpg {
250 | background-image: url("../images/jpg.png");
251 | }
252 |
253 | .fileicon_pdf {
254 | background-image: url("../images/pdf.png");
255 | }
256 |
257 | .fileicon_png {
258 | background-image: url("../images/png.png");
259 | }
260 |
261 | .fileicon_ppt {
262 | background-image: url("../images/ppt.png");
263 | }
264 |
265 | .fileicon_psd {
266 | background-image: url("../images/psd.png");
267 | }
268 |
269 | .fileicon_xls {
270 | background-image: url("../images/xls.png");
271 | }
272 |
273 | .fileicon_txt {
274 | background-image: url("../images/txt.png");
275 | }
276 |
277 | .fileicon_qitageshi {
278 | background-image: url("../images/qitageshi.png");
279 | }
280 |
281 | .file_name p {
282 | float: left;
283 | overflow: hidden;
284 | text-overflow: ellipsis;
285 | white-space: nowrap;
286 | line-height: 56px;
287 | text-indent: 43px;
288 | width: 100%;
289 | box-sizing: border-box;
290 | font-size: 14px;
291 | }
292 |
293 | /*大小*/
294 | .file_size {
295 | overflow: hidden;
296 | text-overflow: ellipsis;
297 | white-space: nowrap;
298 | width: 15%;
299 | float: left;
300 | line-height: 56px;
301 | font-size: 14px;
302 | text-align: center;
303 | }
304 |
305 | /*路径*/
306 | .file_path {
307 | overflow: hidden;
308 | text-overflow: ellipsis;
309 | white-space: nowrap;
310 | width: 20%;
311 | float: left;
312 | text-align: center;
313 | line-height: 56px;
314 | font-size: 14px;
315 | }
316 |
317 | .file_path > a {
318 | color: #0B61A4;
319 | }
320 |
321 | .file_status {
322 | overflow: hidden;
323 | text-overflow: ellipsis;
324 | white-space: nowrap;
325 | width: 20%;
326 | float: left;
327 | margin-top: 8px;
328 | font-size: 14px;
329 | }
330 |
331 | .file_status span {
332 | line-height: 20px;
333 | display: block;
334 | text-align: center;
335 | font-size: 14px;
336 | }
337 |
338 | .file_operate {
339 | overflow: hidden;
340 | text-overflow: ellipsis;
341 | white-space: nowrap;
342 | width: 15%;
343 | float: left;
344 | line-height: 56px;
345 | text-align: center;
346 | font-size: 14px;
347 | }
348 |
349 | .file_operate > div {
350 | width: 18px;
351 | height: 24px;
352 | display: inline-block;
353 | cursor: pointer;
354 | margin-top: 16px;
355 | }
356 |
357 | .file_operate > div:hover {
358 | opacity: .7;
359 | filter: alpha(opacity=70);
360 | }
361 |
362 | .pause {
363 | background: url("../images/pause.png") no-repeat center center;
364 | }
365 |
366 | .start {
367 | background: url("../images/start.png") no-repeat center center;
368 | }
369 |
370 | .cancel {
371 | background: url("../images/cancel.png") no-repeat center center;
372 | }
373 |
374 | /*进度条*/
375 | .progress {
376 | width: 100%;
377 | height: 55px;
378 | position: absolute;
379 | left: 0;
380 | top: 0;
381 | background-color: #fff;
382 | }
383 |
384 | .file_status .processBox_PJY {
385 | text-align: center;
386 | margin-top: 8px;
387 | margin-bottom: 5px
388 | }
389 |
390 | .file_status .processBox_PJY > p {
391 | width: 50%;
392 | height: 8px;
393 | background: #efefef;
394 | margin: 0 auto;
395 | overflow: hidden
396 | }
397 |
398 | .file_status .processBox_PJY > p > span {
399 | display: inline-block;
400 | background: #ffae00;
401 | width: 20%;
402 | height: 8px;
403 | float: left
404 | }
--------------------------------------------------------------------------------
/AnyUploadClient/js/anyupload/dist/anyupload.min.js:
--------------------------------------------------------------------------------
1 | !function(t){t.anyupload||(t.anyupload={});t.anyupload.byteUtil=new function(){this.B_SIZE=1024,this.KB_SIZE=1048576,this.MB_SIZE=1073741824,this.getSpeed=function(t,i){var s=i/(.001*t);return s'+i.getByte(this.file.size)+'
';s.innerHTML=e,this.view=$(s)},this.updateView=function(t){$("#"+this.id+"_text").text(t)},this.updateProgress=function(t){$("#"+this.id+"_progress").attr({style:"width:"+t})},this.init=function(t,i){this.file=t,this.id=i,this.sparkMD5=new SparkMD5.ArrayBuffer,this.fileReader=new FileReader,this.currentChunk=0,this.totalChunk=Math.ceil(this.file.size/s.READ_CHUNK_SIZE),this.status=s.STATUS_INIT,this.nowFoldId=e.nowFoldId,this.nowFoldName=e.nowFoldName,this.createView("等待中.."),juggle.EventDispatcher.apply(this)},this.addListener=function(){this.onStartClickListener(this,this.onStartClick),this.onStopClickListener(this,this.onStopClick),this.onCancelClickListener(this,this.onCancelClick),this.onRetryClickListener(this,this.onRetryClick),this.onFoldClickListener(this,this.onFoldClick),$("#"+this.id+"_start").hide(),$("#"+this.id+"_retry").hide(),this.updateProgress("0%")},this.onStartClickListener=function(t,i){$("#"+this.id+"_start").on("click",function(s){i.call(t,s)})},this.onStopClickListener=function(t,i){$("#"+this.id+"_stop").on("click",function(s){i.call(t,s)})},this.onCancelClickListener=function(t,i){$("#"+this.id+"_cancel").on("click",function(s){i.call(t,s)})},this.onRetryClickListener=function(t,i){$("#"+this.id+"_retry").on("click",function(s){i.call(t,s)})},this.onFoldClickListener=function(t,i){$("#"+this.id+"_fold").on("click",function(s){i.call(t,s)})},this.onStartClick=function(){this.isStop&&(this.isStop=!1,$("#"+this.id+"_start").hide(),$("#"+this.id+"_stop").show(),this.status===s.STATUS_INIT?this.dispatchEventWith(h.ADD_WAIT_MD5_ARRAY):this.status===s.STATUS_START_MD5_CHECK?this.dispatchEventWith(h.ADD_MD5_CHECK_ARRAY_AND_LOAD):this.status===s.STATUS_MD5_SUCCESS?this.dispatchEventWith(h.ADD_MD5_CHECK_ARRAY):this.status===s.STATUS_ENTER_MD5CHECK_ARRAY?this.dispatchEventWith(h.ADD_WAIT_CHECK_ARRAY):this.status===s.STATUS_MD5_CHECK_SUCCESS?this.dispatchEventWith(h.ADD_CHECK_ARRAY):this.status===s.STATUS_ENTER_WAIT_UPLOAD_ARRAY?this.dispatchEventWith(h.ADD_WAIT_UPLOAD_ARRAY):this.status===s.STATUS_RESPONSE_UPLOAD_SUCCESS&&this.dispatchEventWith(h.ADD_UPLOAD_ARRAY))},this.onStopClick=function(){this.isStop=!0},this.onCancelClick=function(){this.status!==s.STATUS_REQUEST_UPLOAD&&this.status!==s.STATUS_RESPONSE_UPLOAD_SUCCESS?this.isCancel=!0:this.dispatchEventWith(h.OPEN_CANCEL_CHOOSE_BOX,this)},this.onRetryClick=function(){},this.onFoldClick=function(){this.dispatchEventWith(h.CHANGE_USER_FOLD)},this.stop=function(){$("#"+this.id+"_start").show(),$("#"+this.id+"_stop").hide(),this.updateView("暂停")},this.clear=function(){this.file=null,this.id=null,this.view=null,this.sparkMD5=null,this.fileReader.removeEventListener("load",this.onLoadFunc),this.fileReader.removeEventListener("error",this.onErrorFunc),this.fileReader=null},this.startMD5Make=function(){this.onLoadListener(this,this.onLoad),this.onErrorListener(this,this.onError),this.loadNext(),this.updateView("生成MD5.."),this.status=s.STATUS_START_MD5_CHECK},this.onLoadListener=function(t,i){this.onLoadFunc=function(s){i.call(t,s)},this.fileReader.addEventListener("load",this.onLoadFunc)},this.onErrorListener=function(t,i){this.onErrorFunc=function(s){i.call(t,s)},this.fileReader.addEventListener("error",this.onErrorFunc)},this.loadNext=function(){var t=this.currentChunk*s.READ_CHUNK_SIZE,i=t+s.READ_CHUNK_SIZE>=this.file.size?this.file.size:t+s.READ_CHUNK_SIZE;this.fileReader.readAsArrayBuffer(s.SLICE.call(this.file,t,i)),this.isLoad=!0},this.onLoad=function(t){if(this.isLoad=!1,this.sparkMD5.append(this.fileReader.result),++this.currentChunk=this.file.size?this.file.size:this.resultData.fileBasePos+this.resultData.uploadMaxLength,e=s.SLICE.call(this.file,this.resultData.fileBasePos,i);this.status=s.STATUS_REQUEST_UPLOAD,this.isLoad=!0,l.uploadFile(this.id,this.userFileId,this.resultData.fileBasePos,i-this.resultData.fileBasePos,[e])}},this.uploadFileSuccess=function(t){if(this.isLoad=!1,1===t.result)this.status=s.STATUS_MD5_MOMENT_UPLOAD,this.updateView("极速上传!"),$("#"+this.id+"_start").hide(),$("#"+this.id+"_stop").hide(),this.updateProgress("100%"),this.dispatchEventWith(h.UPLOAD_COMPLETE);else if(2===t.result){var e=this.resultData.fileBasePos+this.resultData.uploadMaxLength>=this.file.size?this.file.size:this.resultData.fileBasePos+this.resultData.uploadMaxLength;this.status=s.STATUS_RESPONSE_UPLOAD_SUCCESS;var a=(new Date).getTime(),l=a-this.lastTime;this.lastTime=a,this.updateView(i.getSpeed(l,e-this.resultData.fileBasePos)),this.resultData=t,this.updateProgress(this.resultData.fileBasePos/this.file.size*100+"%")}else this.status=s.STATUS_UPLOAD_SUCCESS,this.updateView("上传完成"),$("#"+this.id+"_start").hide(),$("#"+this.id+"_stop").hide(),this.updateProgress("100%"),this.dispatchEventWith(h.UPLOAD_COMPLETE)},this.uploadFileFail=function(t){this.isLoad=!1,this.status=s.STATUS_RESPONSE_UPLOAD_FAIL,this.updateView("md5校验失败"),$("#"+this.id+"_start").hide(),$("#"+this.id+"_stop").hide()}}}(window),function(t){t.anyupload||(t.anyupload={});var i=t.anyupload.fileConfig,s=t.anyupload.uploadEventType,e=t.anyupload.notificationExt,a=t.anyupload.UploadFileObj;t.anyupload.FileMediator=function(){this.uploadFileMap=[],this.waitMD5Array=[],this.md5Array=[],this.waitCheckArray=[],this.checkArray=[],this.waitUploadArray=[],this.uploadArray=[],this.closeArray=[],this.allNum=0,this.nowCompleteNum=0,this.ulContainer=null,this.uploadNumText=null,this.initView=function(t){this.createView(t),juggle.jugglerManager.juggler.add(this)},this.createView=function(t){var i=document.createElement("div"),s='正在上传('+this.nowCompleteNum+"/"+this.allNum+')
';i.innerHTML=s,t.append($(i)),this.ulContainer=$("#anyupload_ul"),this.uploadNumText=$("#anyupload_num")},this.listNotificationInterests=[e.MD5_CHECK_SUCCESS,e.MD5_CHECK_FAIL,e.UPLOAD_FILE_SUCCESS,e.UPLOAD_FILE_FAIL],this.handleNotification=function(t){var i,s;switch(t.name){case e.MD5_CHECK_SUCCESS:i=t.body.result,s=t.body.sendParam,this.uploadFileMap[s.uploadFileId].checkMD5Success(i);break;case e.MD5_CHECK_FAIL:i=t.body.result,s=t.body.sendParam,this.uploadFileMap[s.uploadFileId].checkMD5Fail(i);break;case e.UPLOAD_FILE_SUCCESS:i=t.body.result,s=t.body.sendParam,this.uploadFileMap[s.uploadFileId].uploadFileSuccess(i);break;case e.UPLOAD_FILE_FAIL:i=t.body.result,s=t.body.sendParam,this.uploadFileMap[s.uploadFileId].uploadFileFail(i)}},this.advanceTime=function(t){if(this.md5Array.length' +
36 | '正在上传(' + this.nowCompleteNum + '/' + this.allNum + ')
' +
37 | '' +
38 | '' +
39 | '' +
40 | '
' +
41 | '' +
42 | '' +
50 | '';
54 | view.innerHTML = body;
55 | container.append($(view));
56 | this.ulContainer = $("#anyupload_ul");
57 | this.uploadNumText = $("#anyupload_num");
58 | };
59 | // 关心消息数组
60 | this.listNotificationInterests = [notificationExt.MD5_CHECK_SUCCESS, notificationExt.MD5_CHECK_FAIL, notificationExt.UPLOAD_FILE_SUCCESS, notificationExt.UPLOAD_FILE_FAIL];
61 | // 关心的消息处理
62 | this.handleNotification = function (data) {
63 | var result, sendParam;
64 | switch (data.name) {
65 | case notificationExt.MD5_CHECK_SUCCESS:
66 | result = data.body.result;
67 | sendParam = data.body.sendParam;
68 | this.uploadFileMap[sendParam.uploadFileId].checkMD5Success(result);
69 | break;
70 | case notificationExt.MD5_CHECK_FAIL:
71 | result = data.body.result;
72 | sendParam = data.body.sendParam;
73 | this.uploadFileMap[sendParam.uploadFileId].checkMD5Fail(result);
74 | break;
75 | case notificationExt.UPLOAD_FILE_SUCCESS:
76 | result = data.body.result;
77 | sendParam = data.body.sendParam;
78 | this.uploadFileMap[sendParam.uploadFileId].uploadFileSuccess(result);
79 | break;
80 | case notificationExt.UPLOAD_FILE_FAIL:
81 | result = data.body.result;
82 | sendParam = data.body.sendParam;
83 | this.uploadFileMap[sendParam.uploadFileId].uploadFileFail(result);
84 | break;
85 | }
86 | };
87 | this.advanceTime = function (passedTime) {
88 | if (this.md5Array.length < fileConfig.MAX_MD5_MAKE_FILE_NUM) {
89 | var i, uploadFileObj;
90 | for (i = 0; i < this.waitMD5Array.length; i++) {
91 | uploadFileObj = this.waitMD5Array.shift();
92 | if (uploadFileObj.isStop) {
93 | uploadFileObj.stop();
94 | i--;
95 | // 放入可关闭数组
96 | this.closeArray.push(uploadFileObj);
97 | continue;
98 | }
99 | if (uploadFileObj.isCancel) {
100 | this.removeUploadFile(uploadFileObj);
101 | i--;
102 | continue;
103 | }
104 | this.md5Array.push(uploadFileObj);
105 | uploadFileObj.startMD5Make();
106 | i--;
107 | if (this.md5Array.length === fileConfig.MAX_MD5_MAKE_FILE_NUM) {
108 | break;
109 | }
110 |
111 | }
112 | }
113 | for (i = 0; i < this.md5Array.length; i++) {
114 | uploadFileObj = this.md5Array[i];
115 | // 正在异步,不进行操作
116 | if (uploadFileObj.isLoad) {
117 | continue;
118 | }
119 | if (uploadFileObj.isCancel) {
120 | this.md5Array.splice(i, 1);
121 | this.removeUploadFile(uploadFileObj);
122 | i--;
123 | continue;
124 | }
125 | if (uploadFileObj.isStop) {
126 | this.md5Array.splice(i, 1);
127 | i--;
128 | if (uploadFileObj.status !== fileConfig.STATUS_READ_FILE_FAIL) {
129 | uploadFileObj.stop();
130 | }
131 | // 放入可关闭数组
132 | this.closeArray.push(uploadFileObj);
133 | continue;
134 | }
135 | if (uploadFileObj.status === fileConfig.STATUS_READ_FILE_FAIL) {
136 | // 失败,移出列表不用管了
137 | this.md5Array.splice(i, 1);
138 | i--;
139 | // 放入可关闭数组
140 | this.closeArray.push(uploadFileObj);
141 | } else if (uploadFileObj.status === fileConfig.STATUS_MD5_SUCCESS) {
142 | this.waitCheckArray.push(uploadFileObj);
143 | uploadFileObj.enterMD5CheckArray();
144 | this.md5Array.splice(i, 1);
145 | i--;
146 | }
147 | }
148 | if (this.checkArray.length < fileConfig.MAX_MD5_CHECK_FILE_NUM) {
149 | for (i = 0; i < this.waitCheckArray.length; i++) {
150 | uploadFileObj = this.waitCheckArray.shift();
151 | if (uploadFileObj.isStop) {
152 | uploadFileObj.stop();
153 | i--;
154 | // 放入可关闭数组
155 | this.closeArray.push(uploadFileObj);
156 | continue;
157 | }
158 | if (uploadFileObj.isCancel) {
159 | this.removeUploadFile(uploadFileObj);
160 | i--;
161 | continue;
162 | }
163 | this.checkArray.push(uploadFileObj);
164 | uploadFileObj.startMD5Check();
165 | i--;
166 | if (this.checkArray.length === fileConfig.MAX_MD5_CHECK_FILE_NUM) {
167 | break;
168 | }
169 | }
170 | }
171 | for (i = 0; i < this.checkArray.length; i++) {
172 | uploadFileObj = this.checkArray[i];
173 | if (uploadFileObj.isLoad) {
174 | continue;
175 | }
176 | if (uploadFileObj.isCancel) {
177 | this.checkArray.splice(i, 1);
178 | this.removeUploadFile(uploadFileObj);
179 | i--;
180 | continue;
181 | }
182 | if (uploadFileObj.isStop) {
183 | this.checkArray.splice(i, 1);
184 | i--;
185 | if (uploadFileObj.status !== fileConfig.STATUS_MD5_CHECK_FAIL && uploadFileObj.status !== fileConfig.STATUS_MD5_MOMENT_UPLOAD) {
186 | uploadFileObj.stop();
187 | }
188 | // 放入可关闭数组
189 | this.closeArray.push(uploadFileObj);
190 | continue;
191 | }
192 | if (uploadFileObj.status === fileConfig.STATUS_MD5_CHECK_SUCCESS) {
193 | this.waitUploadArray.push(uploadFileObj);
194 | uploadFileObj.enterWaitUploadArray();
195 | this.checkArray.splice(i, 1);
196 | i--;
197 | } else if (uploadFileObj.status === fileConfig.STATUS_MD5_CHECK_FAIL) {
198 | this.checkArray.splice(i, 1);
199 | i--;
200 | // 放入可关闭数组
201 | this.closeArray.push(uploadFileObj);
202 | } else if (uploadFileObj.status === fileConfig.STATUS_MD5_MOMENT_UPLOAD) {
203 | this.checkArray.splice(i, 1);
204 | i--;
205 | // 放入可关闭数组
206 | this.closeArray.push(uploadFileObj);
207 | }
208 | }
209 | if (this.uploadArray.length < fileConfig.MAX_UPLOAD_FILE_NUM) {
210 | for (i = 0; i < this.waitUploadArray.length; i++) {
211 | uploadFileObj = this.waitUploadArray.shift();
212 | if (uploadFileObj.isStop) {
213 | uploadFileObj.stop();
214 | i--;
215 | // 放入可关闭数组
216 | this.closeArray.push(uploadFileObj);
217 | continue;
218 | }
219 | if (uploadFileObj.isCancel) {
220 | this.removeUploadFile(uploadFileObj);
221 | i--;
222 | continue;
223 | }
224 | this.uploadArray.push(uploadFileObj);
225 | uploadFileObj.startUploadFile();
226 | i--;
227 | if (this.uploadArray.length === fileConfig.MAX_UPLOAD_FILE_NUM) {
228 | break;
229 | }
230 | }
231 | }
232 | for (i = 0; i < this.uploadArray.length; i++) {
233 | uploadFileObj = this.uploadArray[i];
234 | if (uploadFileObj.isLoad) {
235 | continue;
236 | }
237 | if (uploadFileObj.isCancel) {
238 | this.uploadArray.splice(i, 1);
239 | this.removeUploadFile(uploadFileObj);
240 | i--;
241 | continue;
242 | }
243 | if (uploadFileObj.isStop) {
244 | this.uploadArray.splice(i, 1);
245 | i--;
246 | if (uploadFileObj.status !== fileConfig.STATUS_MD5_MOMENT_UPLOAD && uploadFileObj.status !== fileConfig.STATUS_RESPONSE_UPLOAD_FAIL && uploadFileObj.status !== fileConfig.STATUS_UPLOAD_SUCCESS) {
247 | uploadFileObj.stop();
248 | }
249 | // 放入可关闭数组
250 | this.closeArray.push(uploadFileObj);
251 | continue;
252 | }
253 | if (uploadFileObj.status === fileConfig.STATUS_RESPONSE_UPLOAD_FAIL) {
254 | this.uploadArray.splice(i, 1);
255 | i--;
256 | // 放入可关闭数组
257 | this.closeArray.push(uploadFileObj);
258 | } else if (uploadFileObj.status === fileConfig.STATUS_MD5_MOMENT_UPLOAD) {
259 | this.uploadArray.splice(i, 1);
260 | i--;
261 | // 放入可关闭数组
262 | this.closeArray.push(uploadFileObj);
263 | } else if (uploadFileObj.status === fileConfig.STATUS_UPLOAD_SUCCESS) {
264 | this.uploadArray.splice(i, 1);
265 | i--;
266 | // 放入可关闭数组
267 | this.closeArray.push(uploadFileObj);
268 | } else if (uploadFileObj.status === fileConfig.STATUS_RESPONSE_UPLOAD_SUCCESS) {
269 | uploadFileObj.uploadFile(false);
270 | }
271 | }
272 | for (i = 0; i < this.closeArray.length; i++) {
273 | uploadFileObj = this.closeArray[i];
274 | if (uploadFileObj.isCancel) {
275 | this.closeArray.splice(i, 1);
276 | this.removeUploadFile(uploadFileObj);
277 | i--;
278 | }
279 | }
280 | };
281 | this.upLoadFile = function (fileList) {
282 | if (fileList === null || fileList.length === 0) {
283 | return;
284 | }
285 |
286 | for (var i = 0; i < fileList.length; i++) {
287 | var file = fileList[i];
288 | var uploadFileObj = new UploadFileObj();
289 | uploadFileObj.init(file, fileConfig.getIncrementId());
290 | this.ulContainer.append(uploadFileObj.view);
291 | uploadFileObj.addListener();
292 | uploadFileObj.addEventListener(uploadEventType.ADD_WAIT_MD5_ARRAY, this.addWaitMd5Array, this);
293 | uploadFileObj.addEventListener(uploadEventType.ADD_MD5_CHECK_ARRAY_AND_LOAD, this.addMd5CheckArrayAndLoad, this);
294 | uploadFileObj.addEventListener(uploadEventType.ADD_MD5_CHECK_ARRAY, this.addMd5CheckArray, this);
295 | uploadFileObj.addEventListener(uploadEventType.ADD_WAIT_CHECK_ARRAY, this.addWaitCheckArray, this);
296 | uploadFileObj.addEventListener(uploadEventType.ADD_CHECK_ARRAY, this.addCheckArray, this);
297 | uploadFileObj.addEventListener(uploadEventType.ADD_WAIT_UPLOAD_ARRAY, this.addWaitUploadArray, this);
298 | uploadFileObj.addEventListener(uploadEventType.ADD_UPLOAD_ARRAY, this.addUploadArray, this);
299 | uploadFileObj.addEventListener(uploadEventType.UPLOAD_COMPLETE, this.onUploadComplete, this);
300 | uploadFileObj.addEventListener(uploadEventType.OPEN_CANCEL_CHOOSE_BOX, this.onOpenCancelChooseBox, this);
301 | uploadFileObj.addEventListener(uploadEventType.CHANGE_USER_FOLD, this.onChangeUserFold, this);
302 | this.waitMD5Array.push(uploadFileObj);
303 | this.uploadFileMap[uploadFileObj.id] = uploadFileObj;
304 | this.allNum++;
305 | }
306 | this.uploadNumText.text("正在上传(" + this.nowCompleteNum + "/" + this.allNum + ")");
307 | };
308 | this.removeUploadFile = function (uploadFileObj) {
309 | uploadFileObj.view.remove();
310 | this.allNum--;
311 | if (uploadFileObj.status === fileConfig.STATUS_MD5_MOMENT_UPLOAD || uploadFileObj.status === fileConfig.STATUS_UPLOAD_SUCCESS) {
312 | this.nowCompleteNum--;
313 | }
314 | this.uploadNumText.text("正在上传(" + this.nowCompleteNum + "/" + this.allNum + ")");
315 | delete this.uploadFileMap[uploadFileObj.id];
316 | };
317 | this.addWaitMd5Array = function (event) {
318 | var uploadFileObj = event.mTarget;
319 | this.removeCloseArray(uploadFileObj);
320 | this.waitMD5Array.push(uploadFileObj);
321 | };
322 | this.addMd5CheckArrayAndLoad = function (event) {
323 | var uploadFileObj = event.mTarget;
324 | this.removeCloseArray(uploadFileObj);
325 | this.md5Array.push(uploadFileObj);
326 | uploadFileObj.loadNext();
327 |
328 | };
329 | this.addMd5CheckArray = function (event) {
330 | var uploadFileObj = event.mTarget;
331 | this.removeCloseArray(uploadFileObj);
332 | this.md5Array.push(uploadFileObj);
333 | };
334 | this.addWaitCheckArray = function (event) {
335 | var uploadFileObj = event.mTarget;
336 | this.removeCloseArray(uploadFileObj);
337 | this.waitCheckArray.push(uploadFileObj);
338 | };
339 | this.addCheckArray = function (event) {
340 | var uploadFileObj = event.mTarget;
341 | this.removeCloseArray(uploadFileObj);
342 | this.checkArray.push(uploadFileObj);
343 | };
344 | this.addWaitUploadArray = function (event) {
345 | var uploadFileObj = event.mTarget;
346 | this.removeCloseArray(uploadFileObj);
347 | this.waitUploadArray.push(uploadFileObj);
348 | };
349 | this.addUploadArray = function (event) {
350 | var uploadFileObj = event.mTarget;
351 | this.removeCloseArray(uploadFileObj);
352 | this.uploadArray.push(uploadFileObj);
353 |
354 | };
355 | this.removeCloseArray = function (uploadFileObj) {
356 | for (var i = 0; i < this.closeArray.length; i++) {
357 | var uploadFileObj1 = this.closeArray[i];
358 | if (uploadFileObj1.id === uploadFileObj.id) {
359 | this.closeArray.splice(i, 1);
360 | break;
361 | }
362 |
363 | }
364 | };
365 | this.onUploadComplete = function (event) {
366 | this.nowCompleteNum++;
367 | this.uploadNumText.text("正在上传(" + this.nowCompleteNum + "/" + this.allNum + ")");
368 | };
369 | this.onOpenCancelChooseBox = function (event) {
370 | var uploadFileObj = event.mTarget;
371 | uploadFileObj.isCancel = true;
372 | };
373 | this.onChangeUserFold = function (event) {
374 | var uploadFileObj = event.mTarget;
375 | //更换文件夹
376 | //uploadFileObj.nowFoldId
377 | };
378 | juggle.Mediator.apply(this);
379 | };
380 | window.anyupload.FileMediator = FileMediator;
381 | })(window);
--------------------------------------------------------------------------------
/AnyUploadClient/js/anyupload/src/FileSystemStatus.js:
--------------------------------------------------------------------------------
1 | (function (window) {
2 | if (!window.anyupload) window.anyupload = {};
3 | var FileSystemStatus = function () {
4 | this.nowFoldId = "rootId";
5 | this.nowFoldName = "root";
6 | };
7 | window.anyupload.fileSystemStatus = new FileSystemStatus();
8 | })(window);
--------------------------------------------------------------------------------
/AnyUploadClient/js/anyupload/src/NotificationExt.js:
--------------------------------------------------------------------------------
1 | (function (window) {
2 | if (!window.anyupload) window.anyupload = {};
3 | var NotificationExt = function () {
4 | this.MD5_CHECK_SUCCESS = "md5CheckSuccess";
5 | this.MD5_CHECK_FAIL = "md5CheckFail";
6 | this.UPLOAD_FILE_SUCCESS = "uploadFileSuccess";
7 | this.UPLOAD_FILE_FAIL = "uploadFileFail";
8 | };
9 | window.anyupload.notificationExt = new NotificationExt();
10 | })(window);
--------------------------------------------------------------------------------
/AnyUploadClient/js/anyupload/src/PostfixUtil.js:
--------------------------------------------------------------------------------
1 | (function (window) {
2 | if (!window.anyupload) window.anyupload = {};
3 | var PostfixUtil = function () {
4 | this.postfixToClass = [];
5 | this.postfixToClass["ai"] = "fileicon_ai";
6 | this.postfixToClass["doc"] = "fileicon_doc";
7 | this.postfixToClass["docx"] = "fileicon_doc";
8 | this.postfixToClass["jpg"] = "fileicon_jpg";
9 | this.postfixToClass["jpeg"] = "fileicon_jpg";
10 | this.postfixToClass["pdf"] = "fileicon_pdf";
11 | this.postfixToClass["png"] = "fileicon_png";
12 | this.postfixToClass["ppt"] = "fileicon_ppt";
13 | this.postfixToClass["pptx"] = "fileicon_ppt";
14 | this.postfixToClass["psd"] = "fileicon_psd";
15 | this.postfixToClass["xls"] = "fileicon_xls";
16 | this.postfixToClass["txt"] = "fileicon_txt";
17 | this.getClassByFileName = function (userFileName) {
18 | var nameArray = userFileName.toLowerCase().split(".");
19 | if (nameArray.length === 1) {
20 | return "fileicon_qitageshi";
21 | } else {
22 | if (this.postfixToClass[nameArray[nameArray.length - 1]] === null || this.postfixToClass[nameArray[nameArray.length - 1]] === undefined) {
23 | return "fileicon_qitageshi";
24 | } else {
25 | return this.postfixToClass[nameArray[nameArray.length - 1]];
26 | }
27 | }
28 | }
29 | };
30 | window.anyupload.postfixUtil = new PostfixUtil();
31 | })(window);
32 |
--------------------------------------------------------------------------------
/AnyUploadClient/js/anyupload/src/UploadEventType.js:
--------------------------------------------------------------------------------
1 | (function (window) {
2 | if (!window.anyupload) window.anyupload = {};
3 | var UploadEventType = function () {
4 | /** 加入等待md5队列 */
5 | this.ADD_WAIT_MD5_ARRAY = "addWaitMd5Array";
6 | this.ADD_MD5_CHECK_ARRAY_AND_LOAD = "addMd5CheckArrayAndLoad";
7 | this.ADD_MD5_CHECK_ARRAY = "addMd5CheckArray";
8 | this.ADD_WAIT_CHECK_ARRAY = "addWaitCheckArray";
9 | this.ADD_CHECK_ARRAY = "addCheckArray";
10 | this.ADD_WAIT_UPLOAD_ARRAY = "addWaitUploadArray";
11 | this.ADD_UPLOAD_ARRAY = "addUploadArray";
12 | this.UPLOAD_COMPLETE = "uploadComplete";
13 | this.CHANGE_USER_FOLD = "changeUserFold";
14 | this.OPEN_CANCEL_CHOOSE_BOX = "openCancelChooseBox";
15 | };
16 | window.anyupload.uploadEventType = new UploadEventType();
17 | })(window);
--------------------------------------------------------------------------------
/AnyUploadClient/js/anyupload/src/UploadFileObj.js:
--------------------------------------------------------------------------------
1 | (function (window) {
2 | if (!window.anyupload) window.anyupload = {};
3 | var byteUtil = window.anyupload.byteUtil;
4 | var fileConfig = window.anyupload.fileConfig;
5 | var fileSystemStatus = window.anyupload.fileSystemStatus;
6 | var postfixUtil = window.anyupload.postfixUtil;
7 | var uploadEventType = window.anyupload.uploadEventType;
8 | var uploadFileProxy = window.anyupload.uploadFileProxy;
9 | var UploadFileObj = function () {
10 | this.file = null;// 文件
11 | this.id = null;// 唯一id
12 | this.view = null;// 视图
13 | this.sparkMD5 = null;// md5工具
14 | this.fileReader = null;// 读取文件工具
15 | this.currentChunk = null;// 当前块
16 | this.totalChunk = null;// 总块数
17 | this.md5 = null;// md5值说明完成
18 | this.onLoadFunc = null;// 加载完成函数
19 | this.onErrorFunc = null;// 报错函数
20 | this.status = null;// 状态 1:开始,2:读取文件失败,3读取文件成功
21 | this.userFileId = null;// 当前上传得文件id
22 | this.resultData = null;// 返回数据(fileBasePos、uploadMaxLength)
23 | this.lastTime = null;// 上一次时间
24 | this.nowFoldId = null;
25 | this.nowFoldName = null;
26 | this.isStop = false;// 是否暂停
27 | this.isCancel = false;// 是否关闭
28 | this.isLoad = false;// 是否正在异步
29 | this.createView = function (text) {
30 | var view = document.createElement("li");
31 | var body =
32 | '' +
33 | '
' +
34 | '
' +
35 | '
' +
36 | this.file.name +
37 | '
' +
38 | '
' +
39 | '
' +
40 | byteUtil.getByte(this.file.size) +
41 | '
' +
42 | '
' +
45 | '
' +
46 | '
' +
47 | '
' +
48 | '' +
49 | '
' +
50 | '
' +
51 | '
' +
52 | '
' +
53 | '
' +
54 | '
' +
55 | '
' +
56 | '
' +
57 | '
' +
58 | '
' +
59 | '
' +
60 | '
';
61 | view.innerHTML = body;
62 | this.view = $(view);
63 | };
64 | this.updateView = function (text) {
65 | $("#" + this.id + "_text").text(text);
66 | };
67 | this.updateProgress = function (text) {
68 | $("#" + this.id + "_progress").attr({"style": "width:" + text + ""});
69 | };
70 | this.init = function (file, id) {
71 | this.file = file;
72 | this.id = id;
73 | this.sparkMD5 = new SparkMD5.ArrayBuffer();
74 | this.fileReader = new FileReader();
75 | this.currentChunk = 0;
76 | this.totalChunk = Math.ceil(this.file.size / fileConfig.READ_CHUNK_SIZE);
77 | this.status = fileConfig.STATUS_INIT;
78 | this.nowFoldId = fileSystemStatus.nowFoldId;
79 | this.nowFoldName = fileSystemStatus.nowFoldName;
80 | this.createView("等待中..");
81 | juggle.EventDispatcher.apply(this);
82 | };
83 | this.addListener = function () {
84 | this.onStartClickListener(this, this.onStartClick);
85 | this.onStopClickListener(this, this.onStopClick);
86 | this.onCancelClickListener(this, this.onCancelClick);
87 | this.onRetryClickListener(this, this.onRetryClick);
88 | this.onFoldClickListener(this, this.onFoldClick);
89 | $("#" + this.id + "_start").hide();
90 | $("#" + this.id + "_retry").hide();
91 | this.updateProgress("0%");
92 | };
93 | this.onStartClickListener = function (uploadFileObj, call) {
94 | var onLoadFunc = function (event) {
95 | call.call(uploadFileObj, event);
96 | };
97 | $("#" + this.id + "_start").on("click", onLoadFunc);
98 | };
99 | this.onStopClickListener = function (uploadFileObj, call) {
100 | var onLoadFunc = function (event) {
101 | call.call(uploadFileObj, event);
102 | };
103 | $("#" + this.id + "_stop").on("click", onLoadFunc);
104 | };
105 | this.onCancelClickListener = function (uploadFileObj, call) {
106 | var onLoadFunc = function (event) {
107 | call.call(uploadFileObj, event);
108 | };
109 | $("#" + this.id + "_cancel").on("click", onLoadFunc);
110 | };
111 | this.onRetryClickListener = function (uploadFileObj, call) {
112 | var onLoadFunc = function (event) {
113 | call.call(uploadFileObj, event);
114 | };
115 | $("#" + this.id + "_retry").on("click", onLoadFunc);
116 | };
117 | this.onFoldClickListener = function (uploadFileObj, call) {
118 | var onLoadFunc = function (event) {
119 | call.call(uploadFileObj, event);
120 | };
121 | $("#" + this.id + "_fold").on("click", onLoadFunc);
122 | };
123 | this.onStartClick = function () {
124 | if (this.isStop) {
125 | this.isStop = false;
126 | $("#" + this.id + "_start").hide();
127 | $("#" + this.id + "_stop").show();
128 | if (this.status === fileConfig.STATUS_INIT) {
129 | this.dispatchEventWith(uploadEventType.ADD_WAIT_MD5_ARRAY);
130 | } else if (this.status === fileConfig.STATUS_START_MD5_CHECK) {
131 | this.dispatchEventWith(uploadEventType.ADD_MD5_CHECK_ARRAY_AND_LOAD);
132 | } else if (this.status === fileConfig.STATUS_MD5_SUCCESS) {
133 | this.dispatchEventWith(uploadEventType.ADD_MD5_CHECK_ARRAY);
134 | } else if (this.status === fileConfig.STATUS_ENTER_MD5CHECK_ARRAY) {
135 | this.dispatchEventWith(uploadEventType.ADD_WAIT_CHECK_ARRAY);
136 | } else if (this.status === fileConfig.STATUS_MD5_CHECK_SUCCESS) {
137 | this.dispatchEventWith(uploadEventType.ADD_CHECK_ARRAY);
138 | } else if (this.status === fileConfig.STATUS_ENTER_WAIT_UPLOAD_ARRAY) {
139 | this.dispatchEventWith(uploadEventType.ADD_WAIT_UPLOAD_ARRAY);
140 | } else if (this.status === fileConfig.STATUS_RESPONSE_UPLOAD_SUCCESS) {
141 | this.dispatchEventWith(uploadEventType.ADD_UPLOAD_ARRAY);
142 | }
143 |
144 | }
145 | };
146 | this.onStopClick = function () {
147 | this.isStop = true;
148 | };
149 | this.onCancelClick = function () {
150 | if (this.status === fileConfig.STATUS_REQUEST_UPLOAD || this.status === fileConfig.STATUS_RESPONSE_UPLOAD_SUCCESS) {
151 | this.dispatchEventWith(uploadEventType.OPEN_CANCEL_CHOOSE_BOX, this);
152 | return;
153 | }
154 | this.isCancel = true;
155 | };
156 | this.onRetryClick = function () {
157 |
158 | };
159 | this.onFoldClick = function () {
160 | this.dispatchEventWith(uploadEventType.CHANGE_USER_FOLD);
161 | };
162 | this.stop = function () {
163 | $("#" + this.id + "_start").show();
164 | $("#" + this.id + "_stop").hide();
165 | this.updateView("暂停");
166 | };
167 | this.clear = function () {
168 | this.file = null;
169 | this.id = null;
170 | this.view = null;
171 | this.sparkMD5 = null;
172 | this.fileReader.removeEventListener("load", this.onLoadFunc);
173 | this.fileReader.removeEventListener("error", this.onErrorFunc);
174 | this.fileReader = null;
175 | };
176 | this.startMD5Make = function () {
177 | this.onLoadListener(this, this.onLoad);
178 | this.onErrorListener(this, this.onError);
179 | this.loadNext();
180 | this.updateView("生成MD5..");
181 | this.status = fileConfig.STATUS_START_MD5_CHECK;
182 | };
183 | this.onLoadListener = function (uploadFileObj, call) {
184 | this.onLoadFunc = function (event) {
185 | call.call(uploadFileObj, event);
186 | };
187 | this.fileReader.addEventListener("load", this.onLoadFunc);
188 | };
189 | this.onErrorListener = function (uploadFileObj, call) {
190 | this.onErrorFunc = function (event) {
191 | call.call(uploadFileObj, event);
192 | };
193 | this.fileReader.addEventListener("error", this.onErrorFunc);
194 | };
195 | this.loadNext = function () {
196 | var startPos = this.currentChunk * fileConfig.READ_CHUNK_SIZE;
197 | var endPos = startPos + fileConfig.READ_CHUNK_SIZE >= this.file.size ? this.file.size : startPos + fileConfig.READ_CHUNK_SIZE;
198 | this.fileReader.readAsArrayBuffer(fileConfig.SLICE.call(this.file, startPos, endPos));
199 | this.isLoad = true;
200 | };
201 | this.onLoad = function (event) {
202 | this.isLoad = false;
203 | this.sparkMD5.append(this.fileReader.result);
204 | this.currentChunk++;
205 | if (this.currentChunk < this.totalChunk) {
206 | if (this.isStop || this.isCancel) {
207 | return;
208 | }
209 | this.loadNext();
210 | this.updateView("MD5:" + parseInt(this.currentChunk / this.totalChunk * 100) + "%");
211 | } else {
212 | this.md5 = this.sparkMD5.end();
213 | this.updateView("MD5完成");
214 | this.status = fileConfig.STATUS_MD5_SUCCESS;
215 | }
216 | };
217 | this.onError = function (event) {
218 | this.isLoad = false;
219 | this.updateView("生成md5失败,读取文件异常");
220 | this.status = fileConfig.STATUS_READ_FILE_FAIL;
221 | $("#" + this.id + "_start").hide();
222 | $("#" + this.id + "_stop").hide();
223 | };
224 | this.enterMD5CheckArray = function () {
225 | this.status = fileConfig.STATUS_ENTER_MD5CHECK_ARRAY;
226 | this.updateView("等待校验..");
227 | };
228 | this.startMD5Check = function () {
229 | this.updateView("开始校验..");
230 | this.isLoad = true;
231 | this.status = fileConfig.STATUS_START_MD5CHECK;
232 | uploadFileProxy.checkMD5(this.id, this.md5, this.file.name, this.nowFoldId, this.file.size, this.userFileId);
233 |
234 | };
235 | this.checkMD5Success = function (result) {
236 | this.isLoad = false;
237 | if (result.result === 1) {
238 | // 秒传
239 | this.status = fileConfig.STATUS_MD5_MOMENT_UPLOAD;
240 | this.updateView("急速上传!");
241 | $("#" + this.id + "_start").hide();
242 | $("#" + this.id + "_stop").hide();
243 | this.updateProgress("100%");
244 | this.dispatchEventWith(uploadEventType.UPLOAD_COMPLETE);
245 | } else {
246 | // 可以上传
247 | this.status = fileConfig.STATUS_MD5_CHECK_SUCCESS;
248 | this.resultData = result;
249 | this.userFileId = result.userFileId;
250 | this.updateView("校验完成");
251 | }
252 |
253 | };
254 | this.checkMD5Fail = function (result) {
255 | this.isLoad = false;
256 | this.status = fileConfig.STATUS_MD5_CHECK_FAIL;
257 | this.updateView("md5校验失败");
258 | $("#" + this.id + "_start").hide();
259 | $("#" + this.id + "_stop").hide();
260 | };
261 | this.enterWaitUploadArray = function () {
262 | this.status = fileConfig.STATUS_ENTER_WAIT_UPLOAD_ARRAY;
263 | this.updateView("等待中..");
264 | };
265 | this.startUploadFile = function () {
266 | this.updateView("开始上传");
267 | this.lastTime = new Date().getTime();
268 | this.uploadFile(true);
269 |
270 | };
271 | this.uploadFile = function (isStart) {
272 | if (!isStart) {
273 | var nowTime = new Date().getTime();
274 | if ((nowTime - this.lastTime) < this.resultData.waitTime) {
275 | return;
276 | }
277 | }
278 | if (this.resultData.fileBasePos === this.file.size) {
279 | // 上传已经完成了,服务器出问题了
280 | this.status = fileConfig.STATUS_UPLOAD_SUCCESS;
281 | this.updateView("上传完成");
282 | $("#" + this.id + "_start").hide();
283 | $("#" + this.id + "_stop").hide();
284 | this.updateProgress("100%");
285 | this.dispatchEventWith(uploadEventType.UPLOAD_COMPLETE);
286 | return;
287 | }
288 | var endPos = this.resultData.fileBasePos + this.resultData.uploadMaxLength >= this.file.size ? this.file.size : this.resultData.fileBasePos + this.resultData.uploadMaxLength;
289 | var filePart = fileConfig.SLICE.call(this.file, this.resultData.fileBasePos, endPos);
290 | this.status = fileConfig.STATUS_REQUEST_UPLOAD;
291 | this.isLoad = true;
292 | uploadFileProxy.uploadFile(this.id, this.userFileId, this.resultData.fileBasePos, (endPos - this.resultData.fileBasePos), [filePart]);
293 |
294 | };
295 | this.uploadFileSuccess = function (result) {
296 | this.isLoad = false;
297 | if (result.result === 1) {
298 | // 秒传
299 | this.status = fileConfig.STATUS_MD5_MOMENT_UPLOAD;
300 | this.updateView("极速上传!");
301 | $("#" + this.id + "_start").hide();
302 | $("#" + this.id + "_stop").hide();
303 | this.updateProgress("100%");
304 | this.dispatchEventWith(uploadEventType.UPLOAD_COMPLETE);
305 | } else if (result.result === 2) {
306 | var endPos = this.resultData.fileBasePos + this.resultData.uploadMaxLength >= this.file.size ? this.file.size : this.resultData.fileBasePos + this.resultData.uploadMaxLength;
307 | // 可以上传
308 | this.status = fileConfig.STATUS_RESPONSE_UPLOAD_SUCCESS;
309 | var nowTime = new Date().getTime();
310 | var passedTime = nowTime - this.lastTime;
311 | this.lastTime = nowTime;
312 | this.updateView(byteUtil.getSpeed(passedTime, (endPos - this.resultData.fileBasePos)));
313 | this.resultData = result;
314 | this.updateProgress((this.resultData.fileBasePos / this.file.size) * 100 + "%");
315 | } else {
316 | // 秒传
317 | this.status = fileConfig.STATUS_UPLOAD_SUCCESS;
318 | this.updateView("上传完成");
319 | $("#" + this.id + "_start").hide();
320 | $("#" + this.id + "_stop").hide();
321 | this.updateProgress("100%");
322 | this.dispatchEventWith(uploadEventType.UPLOAD_COMPLETE);
323 | }
324 | };
325 | this.uploadFileFail = function (result) {
326 | this.isLoad = false;
327 | this.status = fileConfig.STATUS_RESPONSE_UPLOAD_FAIL;
328 | this.updateView("md5校验失败");
329 | $("#" + this.id + "_start").hide();
330 | $("#" + this.id + "_stop").hide();
331 | };
332 |
333 | };
334 | window.anyupload.UploadFileObj = UploadFileObj;
335 | })(window);
--------------------------------------------------------------------------------
/AnyUploadClient/js/anyupload/src/UploadFileProxy.js:
--------------------------------------------------------------------------------
1 | (function (window) {
2 | if (!window.anyupload) window.anyupload = {};
3 | var notificationExt = window.anyupload.notificationExt;
4 | var UploadFileProxy = function () {
5 | juggle.Proxy.apply(this);
6 | this.url = null;
7 | /**
8 | * 校验md5
9 | * @param uploadFileId 界面上的显示对象id
10 | * @param fileBaseMd5 md5
11 | * @param userFileName 文件名
12 | * @param userFoldParentId 父类id(没用)
13 | * @param fileBaseTotalSize 文件大小
14 | * @param userFileId 文件id(没用)
15 | */
16 | this.checkMD5 = function (uploadFileId, fileBaseMd5, userFileName, userFoldParentId, fileBaseTotalSize, userFileId) {
17 | var data = {
18 | "hOpCode": "50000",
19 | "fileBaseMd5": fileBaseMd5,
20 | "userFileName": userFileName,
21 | "userFoldParentId": userFoldParentId,
22 | "fileBaseTotalSize": fileBaseTotalSize,
23 | "userFileId": userFileId
24 | };
25 | // 用于确认回调到底是哪个文件的消息
26 | var sendParam = {
27 | "data": data,
28 | "uploadFileId": uploadFileId
29 | };
30 | var httpClient = new juggle.HttpClient();
31 | httpClient.sendParam = sendParam;
32 | httpClient.send(data, this.url, null);
33 | httpClient.addEventListener(juggle.httpEventType.SUCCESS, this.checkMD5Success, this);
34 | httpClient.addEventListener(juggle.httpEventType.ERROR, this.checkMD5Fail, this);
35 | };
36 | this.checkMD5Success = function (event) {
37 | var result = JSON.parse(event.mData);
38 | var sendParam = event.mTarget.sendParam;
39 | //返回错误
40 | if (result.hOpCode === "49999") {
41 | this.notifyObservers(this.getNotification(notificationExt.MD5_CHECK_FAIL, {
42 | "result": result,
43 | "sendParam": sendParam
44 | }));
45 | return;
46 | }
47 | //protobuf传0则是null,纠正过来
48 | if (result.fileBasePos === null || result.fileBasePos === undefined) {
49 | result.fileBasePos = 0;
50 | }
51 | this.notifyObservers(this.getNotification(notificationExt.MD5_CHECK_SUCCESS, {
52 | "result": result,
53 | "sendParam": sendParam
54 | }));
55 | };
56 | this.checkMD5Fail = function (event) {
57 | var sendParam = event.mTarget.sendParam;
58 | this.notifyObservers(this.getNotification(notificationExt.MD5_CHECK_FAIL, {
59 | "result": null,
60 | "sendParam": sendParam
61 | }));
62 | };
63 | /**
64 | * 上传文件
65 | * @param uploadFileId 显示对象id
66 | * @param userFileId 文件id
67 | * @param fileBasePos 位置
68 | * @param uploadLength 长度
69 | * @param fileArray 文件块
70 | */
71 | this.uploadFile = function (uploadFileId, userFileId, fileBasePos, uploadLength, fileArray) {
72 | var data = {
73 | "hOpCode": "50001",
74 | "userFileId": userFileId,
75 | "fileBasePos": fileBasePos,
76 | "uploadLength": uploadLength
77 | };
78 | // 用于确认回调到底是哪个文件的消息
79 | var sendParam = {
80 | "data": data,
81 | "uploadFileId": uploadFileId
82 | };
83 |
84 | var httpClient = new juggle.HttpClient();
85 | httpClient.sendParam = sendParam;
86 | httpClient.sendFile(fileArray, data, this.url, null);
87 | httpClient.addEventListener(juggle.httpEventType.SUCCESS, this.uploadFileSuccess, this);
88 | httpClient.addEventListener(juggle.httpEventType.ERROR, this.uploadFileFail, this);
89 | };
90 | this.uploadFileSuccess = function (event) {
91 | var result = JSON.parse(event.mData);
92 | var sendParam = event.mTarget.sendParam;
93 | //错误的返回
94 | if (result.hOpCode === "49999") {
95 | this.notifyObservers(this.getNotification(notificationExt.UPLOAD_FILE_FAIL, {
96 | "result": result,
97 | "sendParam": sendParam
98 | }));
99 | return;
100 | }
101 | //protobuf传0则是null,纠正过来
102 | if (result.fileBasePos === null || result.fileBasePos === undefined) {
103 | result.fileBasePos = 0;
104 | }
105 | this.notifyObservers(this.getNotification(notificationExt.UPLOAD_FILE_SUCCESS, {
106 | "result": result,
107 | "sendParam": sendParam
108 | }));
109 | };
110 | this.uploadFileFail = function (event) {
111 | var sendParam = event.mTarget.sendParam;
112 | this.notifyObservers(this.getNotification(notificationExt.UPLOAD_FILE_FAIL, {
113 | "result": null,
114 | "sendParam": sendParam
115 | }));
116 | }
117 | };
118 | window.anyupload.uploadFileProxy = new UploadFileProxy();
119 | })(window);
--------------------------------------------------------------------------------
/AnyUploadClient/js/lib/juggle-all.min.js:
--------------------------------------------------------------------------------
1 | !function(t){t.juggle||(t.juggle={});t.juggle.tools=new function(){this.indexOf=function(t,e){var i=-1;if(null===t||null===e)return i;for(var s=0;s0){for(var n=0,l=[],o=0;o0?(e=s.pop())[0]=n:e=[n];!i.isNull(n=n.parent);)e[l++]=n;for(var o=0;ol?t-l:0;if(this.mCurrentTime+=t,!(this.mCurrentTime<=0)){this.mCurrentTime>this.mTotalTime&&(this.mCurrentTime=this.mTotalTime),this.mCurrentCycle<0&&(this.mCurrentCycle++,e.isNull(this.mOnStart)||this.mOnStart.call(this,this.mOnStartArgs));var a=this.mCurrentTime/this.mTotalTime,r=this.mReverse&&this.mCurrentCycle%2==1,h=this.mStartValues.length,u=r?this.mTransitionFunc.call(s,1-a):this.mTransitionFunc.call(s,a);for(i=0;i1)this.mCurrentTime=-this.mRepeatDelay,this.mCurrentCycle++,this.mRepeatCount>1&&this.mRepeatCount--,e.isNull(this.mOnRepeat)||this.mOnRepeat.call(this,this.mOnRepeatArgs);else{var c=this.mOnComplete,E=this.mOnCompleteArgs;this.dispatchEventWith(n.REMOVE_FROM_JUGGLER),e.isNull(c)||c.call(this,E)}o&&this.advanceTime(o)}}},this.isComplete=function(){return this.mCurrentTime===this.mTotalTime&&1===this.mRepeatCount},this.setTransition=function(t){this.mTransitionFunc=s.getTransition(t)},this.setDelay=function(t){this.mCurrentTime=this.mCurrentTime+this.mDelay-t,this.mDelay=t},this.reset(t,l,o),i.apply(this)}}(window),function(t){t.juggle||(t.juggle={});var e=t.juggle.tools,i=t.juggle.Tween;t.juggle.tweenPool=new function(){this.sTweenPool=[],this.fromPool=function(t,s,n){return e.isNull(n)&&(n="linear"),this.sTweenPool.length?this.sTweenPool.pop().reset(t,s,n):new i(t,s,n)},this.toPool=function(t){t.mOnStart=t.mOnUpdate=t.mOnRepeat=t.mOnComplete=null,t.mOnStartArgs=t.mOnUpdateArgs=t.mOnRepeatArgs=t.mOnCompleteArgs=null,t.mTarget=null,t.mTransitionFunc=null,t.mProperties.length=0,t.mStartValues.length=0,t.mEndValues.length=0,this.sTweenPool[this.sTweenPool.length]=t}}}(window),function(t){t.juggle||(t.juggle={});var e=t.juggle.tools,i=t.juggle.jugglerEventType,s=t.juggle.EventDispatcher;t.juggle.DelayedCall=function(t,n,l){this.mCurrentTime=null,this.mTotalTime=null,this.mCall=null,this.mArgs=null,this.mRepeatCount=null,this.reset=function(t,i,s){return e.isNull(s)&&(s=null),this.mCurrentTime=0,this.mTotalTime=Math.max(i,1e-4),this.mCall=t,this.mArgs=s,this.mRepeatCount=1,this},this.advanceTime=function(t){var e=this.mCurrentTime;if(this.mCurrentTime=Math.min(this.mTotalTime,this.mCurrentTime+t),this.mCurrentTime===this.mTotalTime)if(0===this.mRepeatCount||this.mRepeatCount>1)this.mRepeatCount>0&&(this.mRepeatCount-=1),this.mCurrentTime=0,null===this.mArgs?this.mCall.call(this):this.mCall.call(this,this.mArgs),this.advanceTime(e+t-this.mTotalTime);else{var s=this.mCall,n=this.mArgs;this.dispatchEventWith(i.REMOVE_FROM_JUGGLER),s.call(this,n)}},this.isComplete=function(){return 1===this.mRepeatCount&&this.mCurrentTime===this.mTotalTime},this.reset(t,n,l),s.apply(this)}}(window),function(t){t.juggle||(t.juggle={});var e=t.juggle.tools,i=t.juggle.DelayedCall;t.juggle.delayedCallPool=new function(){this.sDelayedCallPool=[],this.fromPool=function(t,s,n){return e.isNull(n)&&(n=null),this.sDelayedCallPool.length?this.sDelayedCallPool.pop().reset(t,s,n):new i(t,s,n)},this.toPool=function(t){t.mCall=null,t.mArgs=null,this.sDelayedCallPool[this.sDelayedCallPool.length]=t}}}(window),function(t){t.juggle||(t.juggle={});t.juggle.webSocketEventType=new function(){this.CONNECTED="connected",this.CLOSE="close",this.WSMESSAGE="wsmessage",this.getMessage=function(t){return this.WSMESSAGE+"_"+t}}}(window),function(t){t.juggle||(t.juggle={});t.juggle.webSocketConfig=new function(){this.WSOPCODE="wsOpCode"}}(window),function(window){window.juggle||(window.juggle={});var EventDispatcher=window.juggle.EventDispatcher,webSocketEventType=window.juggle.webSocketEventType,webSocketConfig=window.juggle.webSocketConfig,WebSocketClient=function(url){this.webSocket=null,this.isConnected=!1,this.url=url,this.connect=function(){this.webSocket=new WebSocket(this.url),this.onOpenListener(this,this.onOpen),this.onCloseListener(this,this.onClose),this.onErrorListener(this,this.onError),this.onMessageListener(this,this.onMessage)},this.onOpenListener=function(t,e){t.webSocket.onopen=function(i){e.call(t,i)}},this.onCloseListener=function(t,e){t.webSocket.onclose=function(i){e.call(t,i)}},this.onErrorListener=function(t,e){t.webSocket.onerror=function(i){e.call(t,i)}},this.onMessageListener=function(t,e){t.webSocket.onmessage=function(i){e.call(t,i)}},this.onOpen=function(t){this.isConnected=!0,this.dispatchEventWith(webSocketEventType.CONNECTED)},this.send=function(t){if(this.isConnected){var e=new Blob([JSON.stringify(t)]);this.webSocket.send(e)}else alert("未链接至websocket服务器")},this.onMessage=function(event){var data=eval("("+event.data+")");null!==data[webSocketConfig.WSOPCODE]&&void 0!==data[webSocketConfig.WSOPCODE]&&this.dispatchEventWith(webSocketEventType.getMessage(data[webSocketConfig.WSOPCODE]),!1,data)},this.onClose=function(t){this.isConnected=!1,this.dispatchEventWith(webSocketEventType.CLOSE)},this.onError=function(t){},this.close=function(){this.webSocket.close()},EventDispatcher.apply(this),this.connect()};window.juggle.WebSocketClient=WebSocketClient}(window),function(t){t.juggle||(t.juggle={});t.juggle.httpEventType=new function(){this.ERROR="error",this.SUCCESS="success"}}(window),function(t){t.juggle||(t.juggle={});var e=t.juggle.EventDispatcher,i=t.juggle.httpEventType;t.juggle.HttpClient=function(){e.apply(this),this.send=function(t,e,i,s,n){this.data=t,this.url=e,this.header=i;var l=new XMLHttpRequest;if(null===l||void 0===l)return!1;null!==n&&void 0!==n||(n=!0),null!==s&&void 0!==s||(s=null===t||void 0===t?"get":"post"),this.type=s,this.isAsync=n,l.open(s,e,n);for(var o in i)l.setRequestHeader(o,i[o]);this.addHttpListener(this,l,this.sendReturn,t),"post"===s?(l.setRequestHeader("Content-Type","application/json"),l.send(JSON.stringify(t))):l.send()},this.addHttpListener=function(t,e,i,s){e.onreadystatechange=function(n){i.call(t,e,n,s)}},this.sendReturn=function(t,e,s){4===t.readyState&&(200===t.status?this.dispatchEventWith(i.SUCCESS,!1,t.responseText):this.dispatchEventWith(i.ERROR))},this.sendFile=function(t,e,i,s,n,l){this.data=e,this.url=i,this.header=s;var o=new XMLHttpRequest;if(null===o||void 0===o)return!1;null!==l&&void 0!==l||(l=!0),null!==n&&void 0!==n||(n="post"),this.type=n,this.isAsync=l,o.open(n,i,l);for(var a in s)o.setRequestHeader(a,s[a]);this.addHttpListener(this,o,this.sendReturn,e);for(var r=new FormData,h=0;h0?this.dispatchEventWith(n.LOAD_FAIL):this.dispatchEventWith(n.LOAD_COMPLETE))},this.loadError=function(t){this.failNum++,this.successNum+this.failNum===this.loadList.length&&this.dispatchEventWith(n.LOAD_FAIL)},this.loadList=t,this.resultArray=[],this.successNum=0,this.failNum=0,this.data=l,e.apply(this);for(var o=0;o 0) {
128 | var index = 0;
129 | var restListeners = [];
130 | for (var i = 0; i < numListeners; ++i) {
131 | var otherListener = listeners[i];
132 | if (otherListener !== listener)
133 | restListeners[index++] = otherListener;
134 | }
135 | this.mEventListeners[type] = restListeners;
136 | }
137 | }
138 | };
139 | /**
140 | * 移除某类型监听,传空则移除所有监听(无回调)
141 | * @param type
142 | */
143 | this.removeEventListeners = function (type) {
144 | if (type && this.mEventListeners)
145 | delete this.mEventListeners[type];
146 | else
147 | this.mEventListeners = null;
148 | };
149 | /**
150 | * 派发事件
151 | * @param event
152 | */
153 | this.dispatchEvent = function (event) {
154 | var bubbles = event.mBubbles;
155 | //不冒泡并且无监听或者没有此类型监听,返回
156 | if (!bubbles && (tools.isNull(this.mEventListeners) || !(event.mType in this.mEventListeners)))
157 | return;
158 | //mTarget参数保留,没意义
159 | var previousTarget = event.mTarget;
160 | // 设置目标
161 | event.mTarget = this;
162 | // 冒泡并且是显示对象
163 | if (bubbles && this.isDisplayObject)
164 | this.bubbleEvent(event);
165 | else
166 | this.invokeEvent(event);
167 | if (previousTarget)
168 | event.mTarget = previousTarget;
169 | };
170 | /**
171 | * 回调,回调前确认长度和移除事件函数中重新创建数组意义非凡
172 | * @param event
173 | * @returns {*}
174 | */
175 | this.invokeEvent = function (event) {
176 | var listeners = this.mEventListeners ? this.mEventListeners[event.mType] : null;
177 | var numListeners = tools.isNull(listeners) ? 0 : listeners.length;
178 | if (numListeners) {
179 | // mCurrentTarget当前接到事件的对象
180 | event.mCurrentTarget = this;
181 | for (var i = 0; i < numListeners; ++i) {
182 | var listener = listeners[i];
183 | var numArgs = listener.length;
184 | if (numArgs === 0)
185 | listener.call(this.functionMapping[listener]);
186 | else if (numArgs === 1)
187 | listener.call(this.functionMapping[listener], event);
188 | else
189 | listener.call(this.functionMapping[listener], event, event.mData);
190 | //立即阻止事件派发
191 | if (event.mStopsImmediatePropagation) {
192 | return true;
193 | }
194 | }
195 | //是否阻止冒泡
196 | return event.mStopsPropagation;
197 | } else {
198 | return false;
199 | }
200 | };
201 | /**
202 | * 使用了sBubbleChains数组池,减少垃圾回收
203 | * 提前将冒泡数组确认存入数组,意义非凡
204 | * @param event
205 | */
206 | this.bubbleEvent = function (event) {
207 | var chain;
208 | var element = this;
209 | var length = 1;
210 | if (sBubbleChains.length > 0) {
211 | chain = sBubbleChains.pop();
212 | chain[0] = element;
213 | } else
214 | chain = [element];
215 | while (!tools.isNull(element = element.parent))
216 | chain[length++] = element;
217 | for (var i = 0; i < length; ++i) {
218 | var stopPropagation = chain[i].invokeEvent(event);
219 | if (stopPropagation)
220 | break;
221 | }
222 | chain.length = 0;
223 | sBubbleChains.push(chain);
224 | };
225 | /**
226 | * 派发事件使用对象池
227 | * @param type
228 | * @param bubbles
229 | * @param data
230 | */
231 | this.dispatchEventWith = function (type, bubbles, data) {
232 | if (tools.isNull(bubbles)) {
233 | bubbles = false;
234 | }
235 | if (tools.isNull(data)) {
236 | data = null;
237 | }
238 | //如果冒泡或者自己关注这个事件了
239 | if (bubbles || this.hasEventListener(type)) {
240 | var event = eventPool.fromPool(type, bubbles, data);
241 | this.dispatchEvent(event);
242 | eventPool.toPool(event);
243 | }
244 | };
245 | /**
246 | * 是否关注这个事件
247 | * @param type
248 | * @returns {boolean}
249 | */
250 | this.hasEventListener = function (type) {
251 | var listeners = this.mEventListeners ? this.mEventListeners[type] : null;
252 | return listeners ? listeners.length !== 0 : false;
253 | }
254 | };
255 | window.juggle.EventDispatcher = EventDispatcher;
256 | })(window);
257 |
--------------------------------------------------------------------------------
/AnyUploadClient/js/lib/juggle-event.min.js:
--------------------------------------------------------------------------------
1 | !function(t){t.juggle||(t.juggle={});var n=t.juggle.tools;t.juggle.Event=function(t,e,i){this.mTarget=null,this.mCurrentTarget=null,this.mType=null,this.mBubbles=null,this.mStopsPropagation=null,this.mStopsImmediatePropagation=null,this.mData=null,this.stopPropagation=function(){this.mStopsPropagation=!0},this.stopImmediatePropagation=function(){this.mStopsPropagation=this.mStopsImmediatePropagation=!0},this.reset=function(t,e,i){return n.isNull(e)&&(e=!1),n.isNull(i)&&(i=null),this.mType=t,this.mBubbles=e,this.mData=i,this.mTarget=this.mCurrentTarget=null,this.mStopsPropagation=this.mStopsImmediatePropagation=!1,this},this.reset(t,e,i)}}(window),function(t){t.juggle||(t.juggle={});var n=t.juggle.Event;t.juggle.eventPool=new function(){this.sEventPool=[],this.fromPool=function(t,e,i){return this.sEventPool.length?this.sEventPool.pop().reset(t,e,i):new n(t,e,i)},this.toPool=function(t){t.mData=t.mTarget=t.mCurrentTarget=null,this.sEventPool[this.sEventPool.length]=t}}}(window),function(t){t.juggle||(t.juggle={});var n=t.juggle.eventPool,e=t.juggle.tools,i=[];t.juggle.EventDispatcher=function(){this.mEventListeners=null,this.isEventDispatcher=!0,this.functionMapping=[],this.addEventListener=function(t,n,i){e.isNull(this.mEventListeners)&&(this.mEventListeners=[]);var s=this.mEventListeners[t];e.isNull(s)?(this.mEventListeners[t]=[n],this.functionMapping[n]=i):-1===e.indexOf(s,n)&&(s.push(n),this.functionMapping[n]=i)},this.removeEventListener=function(t,n){if(this.mEventListeners){var e=this.mEventListeners[t],i=e?e.length:0;if(i>0){for(var s=0,o=[],l=0;l0?(n=i.pop())[0]=s:n=[s];!e.isNull(s=s.parent);)n[o++]=s;for(var l=0;l>> (32 - s)), b);
46 | }
47 |
48 | function md5cycle(x, k) {
49 | var a = x[0],
50 | b = x[1],
51 | c = x[2],
52 | d = x[3];
53 |
54 | a += (b & c | ~b & d) + k[0] - 680876936 | 0;
55 | a = (a << 7 | a >>> 25) + b | 0;
56 | d += (a & b | ~a & c) + k[1] - 389564586 | 0;
57 | d = (d << 12 | d >>> 20) + a | 0;
58 | c += (d & a | ~d & b) + k[2] + 606105819 | 0;
59 | c = (c << 17 | c >>> 15) + d | 0;
60 | b += (c & d | ~c & a) + k[3] - 1044525330 | 0;
61 | b = (b << 22 | b >>> 10) + c | 0;
62 | a += (b & c | ~b & d) + k[4] - 176418897 | 0;
63 | a = (a << 7 | a >>> 25) + b | 0;
64 | d += (a & b | ~a & c) + k[5] + 1200080426 | 0;
65 | d = (d << 12 | d >>> 20) + a | 0;
66 | c += (d & a | ~d & b) + k[6] - 1473231341 | 0;
67 | c = (c << 17 | c >>> 15) + d | 0;
68 | b += (c & d | ~c & a) + k[7] - 45705983 | 0;
69 | b = (b << 22 | b >>> 10) + c | 0;
70 | a += (b & c | ~b & d) + k[8] + 1770035416 | 0;
71 | a = (a << 7 | a >>> 25) + b | 0;
72 | d += (a & b | ~a & c) + k[9] - 1958414417 | 0;
73 | d = (d << 12 | d >>> 20) + a | 0;
74 | c += (d & a | ~d & b) + k[10] - 42063 | 0;
75 | c = (c << 17 | c >>> 15) + d | 0;
76 | b += (c & d | ~c & a) + k[11] - 1990404162 | 0;
77 | b = (b << 22 | b >>> 10) + c | 0;
78 | a += (b & c | ~b & d) + k[12] + 1804603682 | 0;
79 | a = (a << 7 | a >>> 25) + b | 0;
80 | d += (a & b | ~a & c) + k[13] - 40341101 | 0;
81 | d = (d << 12 | d >>> 20) + a | 0;
82 | c += (d & a | ~d & b) + k[14] - 1502002290 | 0;
83 | c = (c << 17 | c >>> 15) + d | 0;
84 | b += (c & d | ~c & a) + k[15] + 1236535329 | 0;
85 | b = (b << 22 | b >>> 10) + c | 0;
86 |
87 | a += (b & d | c & ~d) + k[1] - 165796510 | 0;
88 | a = (a << 5 | a >>> 27) + b | 0;
89 | d += (a & c | b & ~c) + k[6] - 1069501632 | 0;
90 | d = (d << 9 | d >>> 23) + a | 0;
91 | c += (d & b | a & ~b) + k[11] + 643717713 | 0;
92 | c = (c << 14 | c >>> 18) + d | 0;
93 | b += (c & a | d & ~a) + k[0] - 373897302 | 0;
94 | b = (b << 20 | b >>> 12) + c | 0;
95 | a += (b & d | c & ~d) + k[5] - 701558691 | 0;
96 | a = (a << 5 | a >>> 27) + b | 0;
97 | d += (a & c | b & ~c) + k[10] + 38016083 | 0;
98 | d = (d << 9 | d >>> 23) + a | 0;
99 | c += (d & b | a & ~b) + k[15] - 660478335 | 0;
100 | c = (c << 14 | c >>> 18) + d | 0;
101 | b += (c & a | d & ~a) + k[4] - 405537848 | 0;
102 | b = (b << 20 | b >>> 12) + c | 0;
103 | a += (b & d | c & ~d) + k[9] + 568446438 | 0;
104 | a = (a << 5 | a >>> 27) + b | 0;
105 | d += (a & c | b & ~c) + k[14] - 1019803690 | 0;
106 | d = (d << 9 | d >>> 23) + a | 0;
107 | c += (d & b | a & ~b) + k[3] - 187363961 | 0;
108 | c = (c << 14 | c >>> 18) + d | 0;
109 | b += (c & a | d & ~a) + k[8] + 1163531501 | 0;
110 | b = (b << 20 | b >>> 12) + c | 0;
111 | a += (b & d | c & ~d) + k[13] - 1444681467 | 0;
112 | a = (a << 5 | a >>> 27) + b | 0;
113 | d += (a & c | b & ~c) + k[2] - 51403784 | 0;
114 | d = (d << 9 | d >>> 23) + a | 0;
115 | c += (d & b | a & ~b) + k[7] + 1735328473 | 0;
116 | c = (c << 14 | c >>> 18) + d | 0;
117 | b += (c & a | d & ~a) + k[12] - 1926607734 | 0;
118 | b = (b << 20 | b >>> 12) + c | 0;
119 |
120 | a += (b ^ c ^ d) + k[5] - 378558 | 0;
121 | a = (a << 4 | a >>> 28) + b | 0;
122 | d += (a ^ b ^ c) + k[8] - 2022574463 | 0;
123 | d = (d << 11 | d >>> 21) + a | 0;
124 | c += (d ^ a ^ b) + k[11] + 1839030562 | 0;
125 | c = (c << 16 | c >>> 16) + d | 0;
126 | b += (c ^ d ^ a) + k[14] - 35309556 | 0;
127 | b = (b << 23 | b >>> 9) + c | 0;
128 | a += (b ^ c ^ d) + k[1] - 1530992060 | 0;
129 | a = (a << 4 | a >>> 28) + b | 0;
130 | d += (a ^ b ^ c) + k[4] + 1272893353 | 0;
131 | d = (d << 11 | d >>> 21) + a | 0;
132 | c += (d ^ a ^ b) + k[7] - 155497632 | 0;
133 | c = (c << 16 | c >>> 16) + d | 0;
134 | b += (c ^ d ^ a) + k[10] - 1094730640 | 0;
135 | b = (b << 23 | b >>> 9) + c | 0;
136 | a += (b ^ c ^ d) + k[13] + 681279174 | 0;
137 | a = (a << 4 | a >>> 28) + b | 0;
138 | d += (a ^ b ^ c) + k[0] - 358537222 | 0;
139 | d = (d << 11 | d >>> 21) + a | 0;
140 | c += (d ^ a ^ b) + k[3] - 722521979 | 0;
141 | c = (c << 16 | c >>> 16) + d | 0;
142 | b += (c ^ d ^ a) + k[6] + 76029189 | 0;
143 | b = (b << 23 | b >>> 9) + c | 0;
144 | a += (b ^ c ^ d) + k[9] - 640364487 | 0;
145 | a = (a << 4 | a >>> 28) + b | 0;
146 | d += (a ^ b ^ c) + k[12] - 421815835 | 0;
147 | d = (d << 11 | d >>> 21) + a | 0;
148 | c += (d ^ a ^ b) + k[15] + 530742520 | 0;
149 | c = (c << 16 | c >>> 16) + d | 0;
150 | b += (c ^ d ^ a) + k[2] - 995338651 | 0;
151 | b = (b << 23 | b >>> 9) + c | 0;
152 |
153 | a += (c ^ (b | ~d)) + k[0] - 198630844 | 0;
154 | a = (a << 6 | a >>> 26) + b | 0;
155 | d += (b ^ (a | ~c)) + k[7] + 1126891415 | 0;
156 | d = (d << 10 | d >>> 22) + a | 0;
157 | c += (a ^ (d | ~b)) + k[14] - 1416354905 | 0;
158 | c = (c << 15 | c >>> 17) + d | 0;
159 | b += (d ^ (c | ~a)) + k[5] - 57434055 | 0;
160 | b = (b << 21 |b >>> 11) + c | 0;
161 | a += (c ^ (b | ~d)) + k[12] + 1700485571 | 0;
162 | a = (a << 6 | a >>> 26) + b | 0;
163 | d += (b ^ (a | ~c)) + k[3] - 1894986606 | 0;
164 | d = (d << 10 | d >>> 22) + a | 0;
165 | c += (a ^ (d | ~b)) + k[10] - 1051523 | 0;
166 | c = (c << 15 | c >>> 17) + d | 0;
167 | b += (d ^ (c | ~a)) + k[1] - 2054922799 | 0;
168 | b = (b << 21 |b >>> 11) + c | 0;
169 | a += (c ^ (b | ~d)) + k[8] + 1873313359 | 0;
170 | a = (a << 6 | a >>> 26) + b | 0;
171 | d += (b ^ (a | ~c)) + k[15] - 30611744 | 0;
172 | d = (d << 10 | d >>> 22) + a | 0;
173 | c += (a ^ (d | ~b)) + k[6] - 1560198380 | 0;
174 | c = (c << 15 | c >>> 17) + d | 0;
175 | b += (d ^ (c | ~a)) + k[13] + 1309151649 | 0;
176 | b = (b << 21 |b >>> 11) + c | 0;
177 | a += (c ^ (b | ~d)) + k[4] - 145523070 | 0;
178 | a = (a << 6 | a >>> 26) + b | 0;
179 | d += (b ^ (a | ~c)) + k[11] - 1120210379 | 0;
180 | d = (d << 10 | d >>> 22) + a | 0;
181 | c += (a ^ (d | ~b)) + k[2] + 718787259 | 0;
182 | c = (c << 15 | c >>> 17) + d | 0;
183 | b += (d ^ (c | ~a)) + k[9] - 343485551 | 0;
184 | b = (b << 21 | b >>> 11) + c | 0;
185 |
186 | x[0] = a + x[0] | 0;
187 | x[1] = b + x[1] | 0;
188 | x[2] = c + x[2] | 0;
189 | x[3] = d + x[3] | 0;
190 | }
191 |
192 | function md5blk(s) {
193 | var md5blks = [],
194 | i; /* Andy King said do it this way. */
195 |
196 | for (i = 0; i < 64; i += 4) {
197 | md5blks[i >> 2] = s.charCodeAt(i) + (s.charCodeAt(i + 1) << 8) + (s.charCodeAt(i + 2) << 16) + (s.charCodeAt(i + 3) << 24);
198 | }
199 | return md5blks;
200 | }
201 |
202 | function md5blk_array(a) {
203 | var md5blks = [],
204 | i; /* Andy King said do it this way. */
205 |
206 | for (i = 0; i < 64; i += 4) {
207 | md5blks[i >> 2] = a[i] + (a[i + 1] << 8) + (a[i + 2] << 16) + (a[i + 3] << 24);
208 | }
209 | return md5blks;
210 | }
211 |
212 | function md51(s) {
213 | var n = s.length,
214 | state = [1732584193, -271733879, -1732584194, 271733878],
215 | i,
216 | length,
217 | tail,
218 | tmp,
219 | lo,
220 | hi;
221 |
222 | for (i = 64; i <= n; i += 64) {
223 | md5cycle(state, md5blk(s.substring(i - 64, i)));
224 | }
225 | s = s.substring(i - 64);
226 | length = s.length;
227 | tail = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
228 | for (i = 0; i < length; i += 1) {
229 | tail[i >> 2] |= s.charCodeAt(i) << ((i % 4) << 3);
230 | }
231 | tail[i >> 2] |= 0x80 << ((i % 4) << 3);
232 | if (i > 55) {
233 | md5cycle(state, tail);
234 | for (i = 0; i < 16; i += 1) {
235 | tail[i] = 0;
236 | }
237 | }
238 |
239 | // Beware that the final length might not fit in 32 bits so we take care of that
240 | tmp = n * 8;
241 | tmp = tmp.toString(16).match(/(.*?)(.{0,8})$/);
242 | lo = parseInt(tmp[2], 16);
243 | hi = parseInt(tmp[1], 16) || 0;
244 |
245 | tail[14] = lo;
246 | tail[15] = hi;
247 |
248 | md5cycle(state, tail);
249 | return state;
250 | }
251 |
252 | function md51_array(a) {
253 | var n = a.length,
254 | state = [1732584193, -271733879, -1732584194, 271733878],
255 | i,
256 | length,
257 | tail,
258 | tmp,
259 | lo,
260 | hi;
261 |
262 | for (i = 64; i <= n; i += 64) {
263 | md5cycle(state, md5blk_array(a.subarray(i - 64, i)));
264 | }
265 |
266 | // Not sure if it is a bug, however IE10 will always produce a sub array of length 1
267 | // containing the last element of the parent array if the sub array specified starts
268 | // beyond the length of the parent array - weird.
269 | // https://connect.microsoft.com/IE/feedback/details/771452/typed-array-subarray-issue
270 | a = (i - 64) < n ? a.subarray(i - 64) : new Uint8Array(0);
271 |
272 | length = a.length;
273 | tail = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
274 | for (i = 0; i < length; i += 1) {
275 | tail[i >> 2] |= a[i] << ((i % 4) << 3);
276 | }
277 |
278 | tail[i >> 2] |= 0x80 << ((i % 4) << 3);
279 | if (i > 55) {
280 | md5cycle(state, tail);
281 | for (i = 0; i < 16; i += 1) {
282 | tail[i] = 0;
283 | }
284 | }
285 |
286 | // Beware that the final length might not fit in 32 bits so we take care of that
287 | tmp = n * 8;
288 | tmp = tmp.toString(16).match(/(.*?)(.{0,8})$/);
289 | lo = parseInt(tmp[2], 16);
290 | hi = parseInt(tmp[1], 16) || 0;
291 |
292 | tail[14] = lo;
293 | tail[15] = hi;
294 |
295 | md5cycle(state, tail);
296 |
297 | return state;
298 | }
299 |
300 | function rhex(n) {
301 | var s = '',
302 | j;
303 | for (j = 0; j < 4; j += 1) {
304 | s += hex_chr[(n >> (j * 8 + 4)) & 0x0F] + hex_chr[(n >> (j * 8)) & 0x0F];
305 | }
306 | return s;
307 | }
308 |
309 | function hex(x) {
310 | var i;
311 | for (i = 0; i < x.length; i += 1) {
312 | x[i] = rhex(x[i]);
313 | }
314 | return x.join('');
315 | }
316 |
317 | // In some cases the fast add32 function cannot be used..
318 | if (hex(md51('hello')) !== '5d41402abc4b2a76b9719d911017c592') {
319 | add32 = function (x, y) {
320 | var lsw = (x & 0xFFFF) + (y & 0xFFFF),
321 | msw = (x >> 16) + (y >> 16) + (lsw >> 16);
322 | return (msw << 16) | (lsw & 0xFFFF);
323 | };
324 | }
325 |
326 | // ---------------------------------------------------
327 |
328 | /**
329 | * ArrayBuffer slice polyfill.
330 | *
331 | * @see https://github.com/ttaubert/node-arraybuffer-slice
332 | */
333 |
334 | if (typeof ArrayBuffer !== 'undefined' && !ArrayBuffer.prototype.slice) {
335 | (function () {
336 | function clamp(val, length) {
337 | val = (val | 0) || 0;
338 |
339 | if (val < 0) {
340 | return Math.max(val + length, 0);
341 | }
342 |
343 | return Math.min(val, length);
344 | }
345 |
346 | ArrayBuffer.prototype.slice = function (from, to) {
347 | var length = this.byteLength,
348 | begin = clamp(from, length),
349 | end = length,
350 | num,
351 | target,
352 | targetArray,
353 | sourceArray;
354 |
355 | if (to !== undefined) {
356 | end = clamp(to, length);
357 | }
358 |
359 | if (begin > end) {
360 | return new ArrayBuffer(0);
361 | }
362 |
363 | num = end - begin;
364 | target = new ArrayBuffer(num);
365 | targetArray = new Uint8Array(target);
366 |
367 | sourceArray = new Uint8Array(this, begin, num);
368 | targetArray.set(sourceArray);
369 |
370 | return target;
371 | };
372 | })();
373 | }
374 |
375 | // ---------------------------------------------------
376 |
377 | /**
378 | * Helpers.
379 | */
380 |
381 | function toUtf8(str) {
382 | if (/[\u0080-\uFFFF]/.test(str)) {
383 | str = unescape(encodeURIComponent(str));
384 | }
385 |
386 | return str;
387 | }
388 |
389 | function utf8Str2ArrayBuffer(str, returnUInt8Array) {
390 | var length = str.length,
391 | buff = new ArrayBuffer(length),
392 | arr = new Uint8Array(buff),
393 | i;
394 |
395 | for (i = 0; i < length; i += 1) {
396 | arr[i] = str.charCodeAt(i);
397 | }
398 |
399 | return returnUInt8Array ? arr : buff;
400 | }
401 |
402 | function arrayBuffer2Utf8Str(buff) {
403 | return String.fromCharCode.apply(null, new Uint8Array(buff));
404 | }
405 |
406 | function concatenateArrayBuffers(first, second, returnUInt8Array) {
407 | var result = new Uint8Array(first.byteLength + second.byteLength);
408 |
409 | result.set(new Uint8Array(first));
410 | result.set(new Uint8Array(second), first.byteLength);
411 |
412 | return returnUInt8Array ? result : result.buffer;
413 | }
414 |
415 | function hexToBinaryString(hex) {
416 | var bytes = [],
417 | length = hex.length,
418 | x;
419 |
420 | for (x = 0; x < length - 1; x += 2) {
421 | bytes.push(parseInt(hex.substr(x, 2), 16));
422 | }
423 |
424 | return String.fromCharCode.apply(String, bytes);
425 | }
426 |
427 | // ---------------------------------------------------
428 |
429 | /**
430 | * SparkMD5 OOP implementation.
431 | *
432 | * Use this class to perform an incremental md5, otherwise use the
433 | * static methods instead.
434 | */
435 |
436 | function SparkMD5() {
437 | // call reset to init the instance
438 | this.reset();
439 | }
440 |
441 | /**
442 | * Appends a string.
443 | * A conversion will be applied if an utf8 string is detected.
444 | *
445 | * @param {String} str The string to be appended
446 | *
447 | * @return {SparkMD5} The instance itself
448 | */
449 | SparkMD5.prototype.append = function (str) {
450 | // Converts the string to utf8 bytes if necessary
451 | // Then append as binary
452 | this.appendBinary(toUtf8(str));
453 |
454 | return this;
455 | };
456 |
457 | /**
458 | * Appends a binary string.
459 | *
460 | * @param {String} contents The binary string to be appended
461 | *
462 | * @return {SparkMD5} The instance itself
463 | */
464 | SparkMD5.prototype.appendBinary = function (contents) {
465 | this._buff += contents;
466 | this._length += contents.length;
467 |
468 | var length = this._buff.length,
469 | i;
470 |
471 | for (i = 64; i <= length; i += 64) {
472 | md5cycle(this._hash, md5blk(this._buff.substring(i - 64, i)));
473 | }
474 |
475 | this._buff = this._buff.substring(i - 64);
476 |
477 | return this;
478 | };
479 |
480 | /**
481 | * Finishes the incremental computation, reseting the internal state and
482 | * returning the result.
483 | *
484 | * @param {Boolean} raw True to get the raw string, false to get the hex string
485 | *
486 | * @return {String} The result
487 | */
488 | SparkMD5.prototype.end = function (raw) {
489 | var buff = this._buff,
490 | length = buff.length,
491 | i,
492 | tail = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
493 | ret;
494 |
495 | for (i = 0; i < length; i += 1) {
496 | tail[i >> 2] |= buff.charCodeAt(i) << ((i % 4) << 3);
497 | }
498 |
499 | this._finish(tail, length);
500 | ret = hex(this._hash);
501 |
502 | if (raw) {
503 | ret = hexToBinaryString(ret);
504 | }
505 |
506 | this.reset();
507 |
508 | return ret;
509 | };
510 |
511 | /**
512 | * Resets the internal state of the computation.
513 | *
514 | * @return {SparkMD5} The instance itself
515 | */
516 | SparkMD5.prototype.reset = function () {
517 | this._buff = '';
518 | this._length = 0;
519 | this._hash = [1732584193, -271733879, -1732584194, 271733878];
520 |
521 | return this;
522 | };
523 |
524 | /**
525 | * Gets the internal state of the computation.
526 | *
527 | * @return {Object} The state
528 | */
529 | SparkMD5.prototype.getState = function () {
530 | return {
531 | buff: this._buff,
532 | length: this._length,
533 | hash: this._hash
534 | };
535 | };
536 |
537 | /**
538 | * Gets the internal state of the computation.
539 | *
540 | * @param {Object} state The state
541 | *
542 | * @return {SparkMD5} The instance itself
543 | */
544 | SparkMD5.prototype.setState = function (state) {
545 | this._buff = state.buff;
546 | this._length = state.length;
547 | this._hash = state.hash;
548 |
549 | return this;
550 | };
551 |
552 | /**
553 | * Releases memory used by the incremental buffer and other additional
554 | * resources. If you plan to use the instance again, use reset instead.
555 | */
556 | SparkMD5.prototype.destroy = function () {
557 | delete this._hash;
558 | delete this._buff;
559 | delete this._length;
560 | };
561 |
562 | /**
563 | * Finish the final calculation based on the tail.
564 | *
565 | * @param {Array} tail The tail (will be modified)
566 | * @param {Number} length The length of the remaining buffer
567 | */
568 | SparkMD5.prototype._finish = function (tail, length) {
569 | var i = length,
570 | tmp,
571 | lo,
572 | hi;
573 |
574 | tail[i >> 2] |= 0x80 << ((i % 4) << 3);
575 | if (i > 55) {
576 | md5cycle(this._hash, tail);
577 | for (i = 0; i < 16; i += 1) {
578 | tail[i] = 0;
579 | }
580 | }
581 |
582 | // Do the final computation based on the tail and length
583 | // Beware that the final length may not fit in 32 bits so we take care of that
584 | tmp = this._length * 8;
585 | tmp = tmp.toString(16).match(/(.*?)(.{0,8})$/);
586 | lo = parseInt(tmp[2], 16);
587 | hi = parseInt(tmp[1], 16) || 0;
588 |
589 | tail[14] = lo;
590 | tail[15] = hi;
591 | md5cycle(this._hash, tail);
592 | };
593 |
594 | /**
595 | * Performs the md5 hash on a string.
596 | * A conversion will be applied if utf8 string is detected.
597 | *
598 | * @param {String} str The string
599 | * @param {Boolean} raw True to get the raw string, false to get the hex string
600 | *
601 | * @return {String} The result
602 | */
603 | SparkMD5.hash = function (str, raw) {
604 | // Converts the string to utf8 bytes if necessary
605 | // Then compute it using the binary function
606 | return SparkMD5.hashBinary(toUtf8(str), raw);
607 | };
608 |
609 | /**
610 | * Performs the md5 hash on a binary string.
611 | *
612 | * @param {String} content The binary string
613 | * @param {Boolean} raw True to get the raw string, false to get the hex string
614 | *
615 | * @return {String} The result
616 | */
617 | SparkMD5.hashBinary = function (content, raw) {
618 | var hash = md51(content),
619 | ret = hex(hash);
620 |
621 | return raw ? hexToBinaryString(ret) : ret;
622 | };
623 |
624 | // ---------------------------------------------------
625 |
626 | /**
627 | * SparkMD5 OOP implementation for array buffers.
628 | *
629 | * Use this class to perform an incremental md5 ONLY for array buffers.
630 | */
631 | SparkMD5.ArrayBuffer = function () {
632 | // call reset to init the instance
633 | this.reset();
634 | };
635 |
636 | /**
637 | * Appends an array buffer.
638 | *
639 | * @param {ArrayBuffer} arr The array to be appended
640 | *
641 | * @return {SparkMD5.ArrayBuffer} The instance itself
642 | */
643 | SparkMD5.ArrayBuffer.prototype.append = function (arr) {
644 | var buff = concatenateArrayBuffers(this._buff.buffer, arr, true),
645 | length = buff.length,
646 | i;
647 |
648 | this._length += arr.byteLength;
649 |
650 | for (i = 64; i <= length; i += 64) {
651 | md5cycle(this._hash, md5blk_array(buff.subarray(i - 64, i)));
652 | }
653 |
654 | this._buff = (i - 64) < length ? new Uint8Array(buff.buffer.slice(i - 64)) : new Uint8Array(0);
655 |
656 | return this;
657 | };
658 |
659 | /**
660 | * Finishes the incremental computation, reseting the internal state and
661 | * returning the result.
662 | *
663 | * @param {Boolean} raw True to get the raw string, false to get the hex string
664 | *
665 | * @return {String} The result
666 | */
667 | SparkMD5.ArrayBuffer.prototype.end = function (raw) {
668 | var buff = this._buff,
669 | length = buff.length,
670 | tail = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
671 | i,
672 | ret;
673 |
674 | for (i = 0; i < length; i += 1) {
675 | tail[i >> 2] |= buff[i] << ((i % 4) << 3);
676 | }
677 |
678 | this._finish(tail, length);
679 | ret = hex(this._hash);
680 |
681 | if (raw) {
682 | ret = hexToBinaryString(ret);
683 | }
684 |
685 | this.reset();
686 |
687 | return ret;
688 | };
689 |
690 | /**
691 | * Resets the internal state of the computation.
692 | *
693 | * @return {SparkMD5.ArrayBuffer} The instance itself
694 | */
695 | SparkMD5.ArrayBuffer.prototype.reset = function () {
696 | this._buff = new Uint8Array(0);
697 | this._length = 0;
698 | this._hash = [1732584193, -271733879, -1732584194, 271733878];
699 |
700 | return this;
701 | };
702 |
703 | /**
704 | * Gets the internal state of the computation.
705 | *
706 | * @return {Object} The state
707 | */
708 | SparkMD5.ArrayBuffer.prototype.getState = function () {
709 | var state = SparkMD5.prototype.getState.call(this);
710 |
711 | // Convert buffer to a string
712 | state.buff = arrayBuffer2Utf8Str(state.buff);
713 |
714 | return state;
715 | };
716 |
717 | /**
718 | * Gets the internal state of the computation.
719 | *
720 | * @param {Object} state The state
721 | *
722 | * @return {SparkMD5.ArrayBuffer} The instance itself
723 | */
724 | SparkMD5.ArrayBuffer.prototype.setState = function (state) {
725 | // Convert string to buffer
726 | state.buff = utf8Str2ArrayBuffer(state.buff, true);
727 |
728 | return SparkMD5.prototype.setState.call(this, state);
729 | };
730 |
731 | SparkMD5.ArrayBuffer.prototype.destroy = SparkMD5.prototype.destroy;
732 |
733 | SparkMD5.ArrayBuffer.prototype._finish = SparkMD5.prototype._finish;
734 |
735 | /**
736 | * Performs the md5 hash on an array buffer.
737 | *
738 | * @param {ArrayBuffer} arr The array buffer
739 | * @param {Boolean} raw True to get the raw string, false to get the hex one
740 | *
741 | * @return {String} The result
742 | */
743 | SparkMD5.ArrayBuffer.hash = function (arr, raw) {
744 | var hash = md51_array(new Uint8Array(arr)),
745 | ret = hex(hash);
746 |
747 | return raw ? hexToBinaryString(ret) : ret;
748 | };
749 |
750 | return SparkMD5;
751 | }));
752 |
--------------------------------------------------------------------------------
/AnyUploadClient/js/lib/spark-md5.min.js:
--------------------------------------------------------------------------------
1 | (function(factory){if(typeof exports==="object"){module.exports=factory()}else if(typeof define==="function"&&define.amd){define(factory)}else{var glob;try{glob=window}catch(e){glob=self}glob.SparkMD5=factory()}})(function(undefined){"use strict";var add32=function(a,b){return a+b&4294967295},hex_chr=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];function cmn(q,a,b,x,s,t){a=add32(add32(a,q),add32(x,t));return add32(a<>>32-s,b)}function md5cycle(x,k){var a=x[0],b=x[1],c=x[2],d=x[3];a+=(b&c|~b&d)+k[0]-680876936|0;a=(a<<7|a>>>25)+b|0;d+=(a&b|~a&c)+k[1]-389564586|0;d=(d<<12|d>>>20)+a|0;c+=(d&a|~d&b)+k[2]+606105819|0;c=(c<<17|c>>>15)+d|0;b+=(c&d|~c&a)+k[3]-1044525330|0;b=(b<<22|b>>>10)+c|0;a+=(b&c|~b&d)+k[4]-176418897|0;a=(a<<7|a>>>25)+b|0;d+=(a&b|~a&c)+k[5]+1200080426|0;d=(d<<12|d>>>20)+a|0;c+=(d&a|~d&b)+k[6]-1473231341|0;c=(c<<17|c>>>15)+d|0;b+=(c&d|~c&a)+k[7]-45705983|0;b=(b<<22|b>>>10)+c|0;a+=(b&c|~b&d)+k[8]+1770035416|0;a=(a<<7|a>>>25)+b|0;d+=(a&b|~a&c)+k[9]-1958414417|0;d=(d<<12|d>>>20)+a|0;c+=(d&a|~d&b)+k[10]-42063|0;c=(c<<17|c>>>15)+d|0;b+=(c&d|~c&a)+k[11]-1990404162|0;b=(b<<22|b>>>10)+c|0;a+=(b&c|~b&d)+k[12]+1804603682|0;a=(a<<7|a>>>25)+b|0;d+=(a&b|~a&c)+k[13]-40341101|0;d=(d<<12|d>>>20)+a|0;c+=(d&a|~d&b)+k[14]-1502002290|0;c=(c<<17|c>>>15)+d|0;b+=(c&d|~c&a)+k[15]+1236535329|0;b=(b<<22|b>>>10)+c|0;a+=(b&d|c&~d)+k[1]-165796510|0;a=(a<<5|a>>>27)+b|0;d+=(a&c|b&~c)+k[6]-1069501632|0;d=(d<<9|d>>>23)+a|0;c+=(d&b|a&~b)+k[11]+643717713|0;c=(c<<14|c>>>18)+d|0;b+=(c&a|d&~a)+k[0]-373897302|0;b=(b<<20|b>>>12)+c|0;a+=(b&d|c&~d)+k[5]-701558691|0;a=(a<<5|a>>>27)+b|0;d+=(a&c|b&~c)+k[10]+38016083|0;d=(d<<9|d>>>23)+a|0;c+=(d&b|a&~b)+k[15]-660478335|0;c=(c<<14|c>>>18)+d|0;b+=(c&a|d&~a)+k[4]-405537848|0;b=(b<<20|b>>>12)+c|0;a+=(b&d|c&~d)+k[9]+568446438|0;a=(a<<5|a>>>27)+b|0;d+=(a&c|b&~c)+k[14]-1019803690|0;d=(d<<9|d>>>23)+a|0;c+=(d&b|a&~b)+k[3]-187363961|0;c=(c<<14|c>>>18)+d|0;b+=(c&a|d&~a)+k[8]+1163531501|0;b=(b<<20|b>>>12)+c|0;a+=(b&d|c&~d)+k[13]-1444681467|0;a=(a<<5|a>>>27)+b|0;d+=(a&c|b&~c)+k[2]-51403784|0;d=(d<<9|d>>>23)+a|0;c+=(d&b|a&~b)+k[7]+1735328473|0;c=(c<<14|c>>>18)+d|0;b+=(c&a|d&~a)+k[12]-1926607734|0;b=(b<<20|b>>>12)+c|0;a+=(b^c^d)+k[5]-378558|0;a=(a<<4|a>>>28)+b|0;d+=(a^b^c)+k[8]-2022574463|0;d=(d<<11|d>>>21)+a|0;c+=(d^a^b)+k[11]+1839030562|0;c=(c<<16|c>>>16)+d|0;b+=(c^d^a)+k[14]-35309556|0;b=(b<<23|b>>>9)+c|0;a+=(b^c^d)+k[1]-1530992060|0;a=(a<<4|a>>>28)+b|0;d+=(a^b^c)+k[4]+1272893353|0;d=(d<<11|d>>>21)+a|0;c+=(d^a^b)+k[7]-155497632|0;c=(c<<16|c>>>16)+d|0;b+=(c^d^a)+k[10]-1094730640|0;b=(b<<23|b>>>9)+c|0;a+=(b^c^d)+k[13]+681279174|0;a=(a<<4|a>>>28)+b|0;d+=(a^b^c)+k[0]-358537222|0;d=(d<<11|d>>>21)+a|0;c+=(d^a^b)+k[3]-722521979|0;c=(c<<16|c>>>16)+d|0;b+=(c^d^a)+k[6]+76029189|0;b=(b<<23|b>>>9)+c|0;a+=(b^c^d)+k[9]-640364487|0;a=(a<<4|a>>>28)+b|0;d+=(a^b^c)+k[12]-421815835|0;d=(d<<11|d>>>21)+a|0;c+=(d^a^b)+k[15]+530742520|0;c=(c<<16|c>>>16)+d|0;b+=(c^d^a)+k[2]-995338651|0;b=(b<<23|b>>>9)+c|0;a+=(c^(b|~d))+k[0]-198630844|0;a=(a<<6|a>>>26)+b|0;d+=(b^(a|~c))+k[7]+1126891415|0;d=(d<<10|d>>>22)+a|0;c+=(a^(d|~b))+k[14]-1416354905|0;c=(c<<15|c>>>17)+d|0;b+=(d^(c|~a))+k[5]-57434055|0;b=(b<<21|b>>>11)+c|0;a+=(c^(b|~d))+k[12]+1700485571|0;a=(a<<6|a>>>26)+b|0;d+=(b^(a|~c))+k[3]-1894986606|0;d=(d<<10|d>>>22)+a|0;c+=(a^(d|~b))+k[10]-1051523|0;c=(c<<15|c>>>17)+d|0;b+=(d^(c|~a))+k[1]-2054922799|0;b=(b<<21|b>>>11)+c|0;a+=(c^(b|~d))+k[8]+1873313359|0;a=(a<<6|a>>>26)+b|0;d+=(b^(a|~c))+k[15]-30611744|0;d=(d<<10|d>>>22)+a|0;c+=(a^(d|~b))+k[6]-1560198380|0;c=(c<<15|c>>>17)+d|0;b+=(d^(c|~a))+k[13]+1309151649|0;b=(b<<21|b>>>11)+c|0;a+=(c^(b|~d))+k[4]-145523070|0;a=(a<<6|a>>>26)+b|0;d+=(b^(a|~c))+k[11]-1120210379|0;d=(d<<10|d>>>22)+a|0;c+=(a^(d|~b))+k[2]+718787259|0;c=(c<<15|c>>>17)+d|0;b+=(d^(c|~a))+k[9]-343485551|0;b=(b<<21|b>>>11)+c|0;x[0]=a+x[0]|0;x[1]=b+x[1]|0;x[2]=c+x[2]|0;x[3]=d+x[3]|0}function md5blk(s){var md5blks=[],i;for(i=0;i<64;i+=4){md5blks[i>>2]=s.charCodeAt(i)+(s.charCodeAt(i+1)<<8)+(s.charCodeAt(i+2)<<16)+(s.charCodeAt(i+3)<<24)}return md5blks}function md5blk_array(a){var md5blks=[],i;for(i=0;i<64;i+=4){md5blks[i>>2]=a[i]+(a[i+1]<<8)+(a[i+2]<<16)+(a[i+3]<<24)}return md5blks}function md51(s){var n=s.length,state=[1732584193,-271733879,-1732584194,271733878],i,length,tail,tmp,lo,hi;for(i=64;i<=n;i+=64){md5cycle(state,md5blk(s.substring(i-64,i)))}s=s.substring(i-64);length=s.length;tail=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(i=0;i>2]|=s.charCodeAt(i)<<(i%4<<3)}tail[i>>2]|=128<<(i%4<<3);if(i>55){md5cycle(state,tail);for(i=0;i<16;i+=1){tail[i]=0}}tmp=n*8;tmp=tmp.toString(16).match(/(.*?)(.{0,8})$/);lo=parseInt(tmp[2],16);hi=parseInt(tmp[1],16)||0;tail[14]=lo;tail[15]=hi;md5cycle(state,tail);return state}function md51_array(a){var n=a.length,state=[1732584193,-271733879,-1732584194,271733878],i,length,tail,tmp,lo,hi;for(i=64;i<=n;i+=64){md5cycle(state,md5blk_array(a.subarray(i-64,i)))}a=i-64>2]|=a[i]<<(i%4<<3)}tail[i>>2]|=128<<(i%4<<3);if(i>55){md5cycle(state,tail);for(i=0;i<16;i+=1){tail[i]=0}}tmp=n*8;tmp=tmp.toString(16).match(/(.*?)(.{0,8})$/);lo=parseInt(tmp[2],16);hi=parseInt(tmp[1],16)||0;tail[14]=lo;tail[15]=hi;md5cycle(state,tail);return state}function rhex(n){var s="",j;for(j=0;j<4;j+=1){s+=hex_chr[n>>j*8+4&15]+hex_chr[n>>j*8&15]}return s}function hex(x){var i;for(i=0;i>16)+(y>>16)+(lsw>>16);return msw<<16|lsw&65535}}if(typeof ArrayBuffer!=="undefined"&&!ArrayBuffer.prototype.slice){(function(){function clamp(val,length){val=val|0||0;if(val<0){return Math.max(val+length,0)}return Math.min(val,length)}ArrayBuffer.prototype.slice=function(from,to){var length=this.byteLength,begin=clamp(from,length),end=length,num,target,targetArray,sourceArray;if(to!==undefined){end=clamp(to,length)}if(begin>end){return new ArrayBuffer(0)}num=end-begin;target=new ArrayBuffer(num);targetArray=new Uint8Array(target);sourceArray=new Uint8Array(this,begin,num);targetArray.set(sourceArray);return target}})()}function toUtf8(str){if(/[\u0080-\uFFFF]/.test(str)){str=unescape(encodeURIComponent(str))}return str}function utf8Str2ArrayBuffer(str,returnUInt8Array){var length=str.length,buff=new ArrayBuffer(length),arr=new Uint8Array(buff),i;for(i=0;i>2]|=buff.charCodeAt(i)<<(i%4<<3)}this._finish(tail,length);ret=hex(this._hash);if(raw){ret=hexToBinaryString(ret)}this.reset();return ret};SparkMD5.prototype.reset=function(){this._buff="";this._length=0;this._hash=[1732584193,-271733879,-1732584194,271733878];return this};SparkMD5.prototype.getState=function(){return{buff:this._buff,length:this._length,hash:this._hash}};SparkMD5.prototype.setState=function(state){this._buff=state.buff;this._length=state.length;this._hash=state.hash;return this};SparkMD5.prototype.destroy=function(){delete this._hash;delete this._buff;delete this._length};SparkMD5.prototype._finish=function(tail,length){var i=length,tmp,lo,hi;tail[i>>2]|=128<<(i%4<<3);if(i>55){md5cycle(this._hash,tail);for(i=0;i<16;i+=1){tail[i]=0}}tmp=this._length*8;tmp=tmp.toString(16).match(/(.*?)(.{0,8})$/);lo=parseInt(tmp[2],16);hi=parseInt(tmp[1],16)||0;tail[14]=lo;tail[15]=hi;md5cycle(this._hash,tail)};SparkMD5.hash=function(str,raw){return SparkMD5.hashBinary(toUtf8(str),raw)};SparkMD5.hashBinary=function(content,raw){var hash=md51(content),ret=hex(hash);return raw?hexToBinaryString(ret):ret};SparkMD5.ArrayBuffer=function(){this.reset()};SparkMD5.ArrayBuffer.prototype.append=function(arr){var buff=concatenateArrayBuffers(this._buff.buffer,arr,true),length=buff.length,i;this._length+=arr.byteLength;for(i=64;i<=length;i+=64){md5cycle(this._hash,md5blk_array(buff.subarray(i-64,i)))}this._buff=i-64>2]|=buff[i]<<(i%4<<3)}this._finish(tail,length);ret=hex(this._hash);if(raw){ret=hexToBinaryString(ret)}this.reset();return ret};SparkMD5.ArrayBuffer.prototype.reset=function(){this._buff=new Uint8Array(0);this._length=0;this._hash=[1732584193,-271733879,-1732584194,271733878];return this};SparkMD5.ArrayBuffer.prototype.getState=function(){var state=SparkMD5.prototype.getState.call(this);state.buff=arrayBuffer2Utf8Str(state.buff);return state};SparkMD5.ArrayBuffer.prototype.setState=function(state){state.buff=utf8Str2ArrayBuffer(state.buff,true);return SparkMD5.prototype.setState.call(this,state)};SparkMD5.ArrayBuffer.prototype.destroy=SparkMD5.prototype.destroy;SparkMD5.ArrayBuffer.prototype._finish=SparkMD5.prototype._finish;SparkMD5.ArrayBuffer.hash=function(arr,raw){var hash=md51_array(new Uint8Array(arr)),ret=hex(hash);return raw?hexToBinaryString(ret):ret};return SparkMD5});
2 |
--------------------------------------------------------------------------------
/AnyUploadServer/.gitignore:
--------------------------------------------------------------------------------
1 | .settings
2 | .classpath
3 | .project
4 | build
5 | dist
--------------------------------------------------------------------------------
/AnyUploadServer/WebContent/META-INF/MANIFEST.MF:
--------------------------------------------------------------------------------
1 | Manifest-Version: 1.0
2 | Class-Path:
3 |
4 |
--------------------------------------------------------------------------------
/AnyUploadServer/WebContent/WEB-INF/lib/commons-beanutils-1.9.3.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dianbaer/anyupload/6078d0b7626b9672df08c012b9d2946326a7f0b1/AnyUploadServer/WebContent/WEB-INF/lib/commons-beanutils-1.9.3.jar
--------------------------------------------------------------------------------
/AnyUploadServer/WebContent/WEB-INF/lib/commons-collections-3.2.2.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dianbaer/anyupload/6078d0b7626b9672df08c012b9d2946326a7f0b1/AnyUploadServer/WebContent/WEB-INF/lib/commons-collections-3.2.2.jar
--------------------------------------------------------------------------------
/AnyUploadServer/WebContent/WEB-INF/lib/commons-fileupload-1.3.2.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dianbaer/anyupload/6078d0b7626b9672df08c012b9d2946326a7f0b1/AnyUploadServer/WebContent/WEB-INF/lib/commons-fileupload-1.3.2.jar
--------------------------------------------------------------------------------
/AnyUploadServer/WebContent/WEB-INF/lib/commons-io-2.5.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dianbaer/anyupload/6078d0b7626b9672df08c012b9d2946326a7f0b1/AnyUploadServer/WebContent/WEB-INF/lib/commons-io-2.5.jar
--------------------------------------------------------------------------------
/AnyUploadServer/WebContent/WEB-INF/lib/commons-lang-2.6.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dianbaer/anyupload/6078d0b7626b9672df08c012b9d2946326a7f0b1/AnyUploadServer/WebContent/WEB-INF/lib/commons-lang-2.6.jar
--------------------------------------------------------------------------------
/AnyUploadServer/WebContent/WEB-INF/lib/commons-logging-1.2.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dianbaer/anyupload/6078d0b7626b9672df08c012b9d2946326a7f0b1/AnyUploadServer/WebContent/WEB-INF/lib/commons-logging-1.2.jar
--------------------------------------------------------------------------------
/AnyUploadServer/WebContent/WEB-INF/lib/ezmorph-1.0.6.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dianbaer/anyupload/6078d0b7626b9672df08c012b9d2946326a7f0b1/AnyUploadServer/WebContent/WEB-INF/lib/ezmorph-1.0.6.jar
--------------------------------------------------------------------------------
/AnyUploadServer/WebContent/WEB-INF/lib/httpserver-1.0.0.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dianbaer/anyupload/6078d0b7626b9672df08c012b9d2946326a7f0b1/AnyUploadServer/WebContent/WEB-INF/lib/httpserver-1.0.0.jar
--------------------------------------------------------------------------------
/AnyUploadServer/WebContent/WEB-INF/lib/javax.servlet-api-3.1.0.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dianbaer/anyupload/6078d0b7626b9672df08c012b9d2946326a7f0b1/AnyUploadServer/WebContent/WEB-INF/lib/javax.servlet-api-3.1.0.jar
--------------------------------------------------------------------------------
/AnyUploadServer/WebContent/WEB-INF/lib/json-lib-2.4-jdk15.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dianbaer/anyupload/6078d0b7626b9672df08c012b9d2946326a7f0b1/AnyUploadServer/WebContent/WEB-INF/lib/json-lib-2.4-jdk15.jar
--------------------------------------------------------------------------------
/AnyUploadServer/WebContent/WEB-INF/lib/log-1.0.0.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dianbaer/anyupload/6078d0b7626b9672df08c012b9d2946326a7f0b1/AnyUploadServer/WebContent/WEB-INF/lib/log-1.0.0.jar
--------------------------------------------------------------------------------
/AnyUploadServer/WebContent/WEB-INF/lib/log4j-1.2.17.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dianbaer/anyupload/6078d0b7626b9672df08c012b9d2946326a7f0b1/AnyUploadServer/WebContent/WEB-INF/lib/log4j-1.2.17.jar
--------------------------------------------------------------------------------
/AnyUploadServer/WebContent/WEB-INF/lib/protobuf-java-3.1.0.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dianbaer/anyupload/6078d0b7626b9672df08c012b9d2946326a7f0b1/AnyUploadServer/WebContent/WEB-INF/lib/protobuf-java-3.1.0.jar
--------------------------------------------------------------------------------
/AnyUploadServer/WebContent/WEB-INF/lib/protobuf-java-format-1.4.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dianbaer/anyupload/6078d0b7626b9672df08c012b9d2946326a7f0b1/AnyUploadServer/WebContent/WEB-INF/lib/protobuf-java-format-1.4.jar
--------------------------------------------------------------------------------
/AnyUploadServer/WebContent/WEB-INF/lib/slf4j-api-1.7.22.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dianbaer/anyupload/6078d0b7626b9672df08c012b9d2946326a7f0b1/AnyUploadServer/WebContent/WEB-INF/lib/slf4j-api-1.7.22.jar
--------------------------------------------------------------------------------
/AnyUploadServer/WebContent/WEB-INF/lib/slf4j-log4j12-1.7.22.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dianbaer/anyupload/6078d0b7626b9672df08c012b9d2946326a7f0b1/AnyUploadServer/WebContent/WEB-INF/lib/slf4j-log4j12-1.7.22.jar
--------------------------------------------------------------------------------
/AnyUploadServer/WebContent/WEB-INF/web.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | AnyUploadServer
4 |
5 |
6 | InitHttpServer
7 | org.grain.httpserver.InitHttpServer
8 | 0
9 |
10 |
11 |
12 | InitHttpServer
13 | /s
14 |
15 |
16 |
17 | Expand
18 | org.anyupload.Expand
19 |
20 |
21 |
22 | ILog
23 | org.anyupload.HttpLog
24 |
25 |
26 | index.html
27 | index.htm
28 | index.jsp
29 | default.html
30 | default.htm
31 | default.jsp
32 |
33 |
--------------------------------------------------------------------------------
/AnyUploadServer/build-Server.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
--------------------------------------------------------------------------------
/AnyUploadServer/protobuf/ErrorProto.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 | package org.anyupload.protobuf;
3 | message ErrorS{
4 | string hOpCode=1;
5 | ErrorCode errorCode=2;
6 | string errorHOpCode=3;
7 | string extraMsg=4;
8 | }
9 | enum ErrorCode{
10 | ERROR_CODE_0=0;//md5校验失败
11 | ERROR_CODE_1=1;//上传失败,不存在这个文件
12 | ERROR_CODE_2=2;//上传失败,上传位置不对
13 | ERROR_CODE_3=3;//上传失败,长度不对
14 | ERROR_CODE_4=4;//上传失败,没发送文件
15 | ERROR_CODE_5=5;//上传失败,不存在实体文件
16 | ERROR_CODE_6=6;//上传失败,时间超前
17 | ERROR_CODE_7=7;//上传失败,更换基础文件失败
18 | ERROR_CODE_8=8;//上传失败,写入文件失败
19 | ERROR_CODE_9=9;//上传失败,更新数据失败
20 | }
--------------------------------------------------------------------------------
/AnyUploadServer/protobuf/UploadFileProto.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 | package org.anyupload.protobuf;
3 | message MD5CheckC{
4 | string hOpCode=1;
5 | string fileBaseMd5=2;//md5
6 | string userFileName=3;//文件名
7 | string userFoldParentId=4;//父类文件夹id
8 | int64 fileBaseTotalSize=5;//文件总大小
9 | string userFileId=6;//文件id
10 | }
11 | message MD5CheckS{
12 | string hOpCode=1;
13 | int32 result=2;//结果1:秒传,2:可以上传
14 | int64 fileBasePos=3;//开始位置
15 | int32 uploadMaxLength=4;//一次上传最大长度
16 | string userFileId=5;//文件id
17 | }
18 | message UploadFileC{
19 | string hOpCode=1;
20 | string userFileId=2;//文件id
21 | int64 fileBasePos=3;//开始位置
22 | int32 uploadLength=4;//上传的长度
23 | }
24 | message UploadFileS{
25 | string hOpCode=1;
26 | int32 result=2;//结果1:秒传,2:可以上传,3上传完成
27 | int64 fileBasePos=3;//开始位置
28 | int32 uploadMaxLength=4;//一次上传最大长度
29 | string userFileId=5;//文件id
30 | int32 waitTime=6;//等待时间
31 | }
32 |
--------------------------------------------------------------------------------
/AnyUploadServer/protobuf/protobuf编译.bat:
--------------------------------------------------------------------------------
1 | C:
2 | cd C:\Users\admin\Desktop\github\anyupload\trunk\AnyUploadServer\protobuf
3 | protoc --java_out=./ UploadFileProto.proto
4 | protoc --java_out=./ ErrorProto.proto
5 | pause
--------------------------------------------------------------------------------
/AnyUploadServer/protobuf/protoc.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dianbaer/anyupload/6078d0b7626b9672df08c012b9d2946326a7f0b1/AnyUploadServer/protobuf/protoc.exe
--------------------------------------------------------------------------------
/AnyUploadServer/src/main/java/log4j.properties:
--------------------------------------------------------------------------------
1 | [properties]
2 | log4j.rootLogger = INFO,console
3 |
4 | log4j.appender.console = org.apache.log4j.ConsoleAppender
5 | log4j.appender.console.layout = org.apache.log4j.PatternLayout
6 | log4j.appender.console.layout.ConversionPattern = %-5p %d [%F,%L] - %m%n
7 |
8 | log4j.logger.httpLog = INFO,httpInfo,httpError,httpWarn
9 |
10 | log4j.logger.httpInfo=httpInfo
11 | log4j.appender.httpInfo = org.anyupload.MyAppender
12 | log4j.appender.httpInfo.Threshold=INFO
13 | log4j.appender.httpInfo.layout = org.apache.log4j.PatternLayout
14 | log4j.appender.httpInfo.datePattern = '.'yyyyMMdd
15 | log4j.appender.httpInfo.append = true
16 | log4j.appender.httpInfo.layout.ConversionPattern = %-5p %d [%F,%L] - %m%n
17 | log4j.appender.httpInfo.File = ${catalina.base}/logs/AnyUploadServer/httpInfo.log
18 |
19 | log4j.logger.httpWarn=httpWarn
20 | log4j.appender.httpWarn = org.anyupload.MyAppender
21 | log4j.appender.httpWarn.Threshold=WARN
22 | log4j.appender.httpWarn.layout = org.apache.log4j.PatternLayout
23 | log4j.appender.httpWarn.datePattern = '.'yyyyMMdd
24 | log4j.appender.httpWarn.append = true
25 | log4j.appender.httpWarn.layout.ConversionPattern = %-5p %d [%F,%L] - %m%n
26 | log4j.appender.httpWarn.File = ${catalina.base}/logs/AnyUploadServer/httpWarn.log
27 |
28 | log4j.logger.httpError=httpError
29 | log4j.appender.httpError = org.anyupload.MyAppender
30 | log4j.appender.httpError.Threshold=ERROR
31 | log4j.appender.httpError.layout = org.apache.log4j.PatternLayout
32 | log4j.appender.httpError.datePattern = '.'yyyyMMdd
33 | log4j.appender.httpError.append = true
34 | log4j.appender.httpError.layout.ConversionPattern = %-5p %d [%F,%L] - %m%n
35 | log4j.appender.httpError.File = ${catalina.base}/logs/AnyUploadServer/httpError.log
36 |
--------------------------------------------------------------------------------
/AnyUploadServer/src/main/java/org/anyupload/CommonConfig.java:
--------------------------------------------------------------------------------
1 | package org.anyupload;
2 |
3 | public class CommonConfig {
4 | /**
5 | * 基础文件路径
6 | */
7 | public static String FILE_BASE_PATH = "FileBasePath";
8 | /**
9 | * 最大上传长度
10 | */
11 | public static int UPLOAD_MAX_LENGTH = 65536;
12 | /**
13 | * 客户端下一次上传文件间隔
14 | */
15 | public static int WAIT_TIME = 640;
16 | /**
17 | * 一次性写入文件的大小
18 | */
19 | public static int ONCE_WRITE_FILE_SIZE = 65536;
20 | }
21 |
--------------------------------------------------------------------------------
/AnyUploadServer/src/main/java/org/anyupload/Expand.java:
--------------------------------------------------------------------------------
1 | package org.anyupload;
2 |
3 | import javax.servlet.http.HttpServlet;
4 |
5 | import org.grain.httpserver.HttpManager;
6 | import org.grain.httpserver.IExpandServer;
7 |
8 | public class Expand implements IExpandServer {
9 |
10 | @Override
11 | public void init(HttpServlet servlet) throws Exception {
12 | // 初始化映射
13 | HOpCode.init();
14 | // 初始化服务
15 | HttpManager.addHttpListener(new UploadService());
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/AnyUploadServer/src/main/java/org/anyupload/FileBase.java:
--------------------------------------------------------------------------------
1 | package org.anyupload;
2 |
3 | import java.util.Date;
4 |
5 | public class FileBase {
6 | /**
7 | * uuid
8 | */
9 | private String fileBaseId;
10 | /**
11 | * 真实路径
12 | */
13 | private String fileBaseRealPath;
14 | /**
15 | * md5
16 | */
17 | private String fileBaseMd5;
18 | /**
19 | * 当前状态1完成,2正在上传
20 | */
21 | private int fileBaseState;
22 | /**
23 | * 总大小
24 | */
25 | private long fileBaseTotalSize;
26 | /**
27 | * 当前上传位置
28 | */
29 | private long fileBasePos;
30 | /**
31 | * 创建时间
32 | */
33 | private Date fileBaseCreateTime;
34 | /**
35 | * 完成时间
36 | */
37 | private Date fileBaseCompleteTime;
38 | /**
39 | * 下一次上传时间
40 | */
41 | private Date fileBaseNextUploadTime;
42 |
43 | public String getFileBaseId() {
44 | return fileBaseId;
45 | }
46 |
47 | public void setFileBaseId(String fileBaseId) {
48 | this.fileBaseId = fileBaseId;
49 | }
50 |
51 | public String getFileBaseRealPath() {
52 | return fileBaseRealPath;
53 | }
54 |
55 | public void setFileBaseRealPath(String fileBaseRealPath) {
56 | this.fileBaseRealPath = fileBaseRealPath;
57 | }
58 |
59 | public String getFileBaseMd5() {
60 | return fileBaseMd5;
61 | }
62 |
63 | public void setFileBaseMd5(String fileBaseMd5) {
64 | this.fileBaseMd5 = fileBaseMd5;
65 | }
66 |
67 | public int getFileBaseState() {
68 | return fileBaseState;
69 | }
70 |
71 | public void setFileBaseState(int fileBaseState) {
72 | this.fileBaseState = fileBaseState;
73 | }
74 |
75 | public long getFileBaseTotalSize() {
76 | return fileBaseTotalSize;
77 | }
78 |
79 | public void setFileBaseTotalSize(long fileBaseTotalSize) {
80 | this.fileBaseTotalSize = fileBaseTotalSize;
81 | }
82 |
83 | public long getFileBasePos() {
84 | return fileBasePos;
85 | }
86 |
87 | public void setFileBasePos(long fileBasePos) {
88 | this.fileBasePos = fileBasePos;
89 | }
90 |
91 | public Date getFileBaseCreateTime() {
92 | return fileBaseCreateTime;
93 | }
94 |
95 | public void setFileBaseCreateTime(Date fileBaseCreateTime) {
96 | this.fileBaseCreateTime = fileBaseCreateTime;
97 | }
98 |
99 | public Date getFileBaseCompleteTime() {
100 | return fileBaseCompleteTime;
101 | }
102 |
103 | public void setFileBaseCompleteTime(Date fileBaseCompleteTime) {
104 | this.fileBaseCompleteTime = fileBaseCompleteTime;
105 | }
106 |
107 | public Date getFileBaseNextUploadTime() {
108 | return fileBaseNextUploadTime;
109 | }
110 |
111 | public void setFileBaseNextUploadTime(Date fileBaseNextUploadTime) {
112 | this.fileBaseNextUploadTime = fileBaseNextUploadTime;
113 | }
114 |
115 | }
--------------------------------------------------------------------------------
/AnyUploadServer/src/main/java/org/anyupload/FileBaseConfig.java:
--------------------------------------------------------------------------------
1 | package org.anyupload;
2 |
3 | public class FileBaseConfig {
4 | /**
5 | * 上传完成
6 | */
7 | public static int STATE_COMPLETE = 1;
8 | /**
9 | * 正在上传
10 | */
11 | public static int STATE_UPLOADING = 2;
12 | }
13 |
--------------------------------------------------------------------------------
/AnyUploadServer/src/main/java/org/anyupload/HOpCode.java:
--------------------------------------------------------------------------------
1 | package org.anyupload;
2 |
3 | import org.anyupload.protobuf.ErrorProto.ErrorS;
4 | import org.anyupload.protobuf.UploadFileProto.MD5CheckC;
5 | import org.anyupload.protobuf.UploadFileProto.MD5CheckS;
6 | import org.anyupload.protobuf.UploadFileProto.UploadFileC;
7 | import org.anyupload.protobuf.UploadFileProto.UploadFileS;
8 | import org.grain.httpserver.HttpManager;
9 |
10 | public class HOpCode {
11 | /**
12 | * 错误
13 | */
14 | public static String ERROR = "49999";
15 | /**
16 | * md5校验
17 | */
18 | public static String MD5_CHECK = "50000";
19 | /**
20 | * 上传文件
21 | */
22 | public static String UPLOAD_FILE = "50001";
23 |
24 | public static void init() {
25 | HttpManager.addMapping(ERROR, null, ErrorS.class);
26 | HttpManager.addMapping(MD5_CHECK, MD5CheckC.class, MD5CheckS.class);
27 | HttpManager.addMapping(UPLOAD_FILE, UploadFileC.class, UploadFileS.class);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/AnyUploadServer/src/main/java/org/anyupload/HttpLog.java:
--------------------------------------------------------------------------------
1 | package org.anyupload;
2 |
3 | import org.grain.log.ILog;
4 | import org.slf4j.Logger;
5 | import org.slf4j.LoggerFactory;
6 |
7 | public class HttpLog implements ILog {
8 | private Logger log;
9 |
10 | public HttpLog() {
11 | this.log = LoggerFactory.getLogger("httpLog");
12 | }
13 |
14 | @Override
15 | public void warn(String warn) {
16 | this.log.warn(warn);
17 | }
18 |
19 | @Override
20 | public void error(String error, Throwable e) {
21 | this.log.error(error, e);
22 | }
23 |
24 | @Override
25 | public void info(String info) {
26 | this.log.info(info);
27 | }
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/AnyUploadServer/src/main/java/org/anyupload/IUserFileAction.java:
--------------------------------------------------------------------------------
1 | package org.anyupload;
2 |
3 | import java.io.File;
4 |
5 | public interface IUserFileAction {
6 | /**
7 | * 根据md5获取已经存在并且上传完成的
8 | *
9 | * @param fileBaseMd5
10 | * @return
11 | */
12 | public FileBase getFileBaseByMd5(String fileBaseMd5);
13 |
14 | /**
15 | * 根据文件id获取文件
16 | *
17 | * @param userFileId
18 | * @return
19 | */
20 | public UserFile getUserFile(String userFileId);
21 |
22 | /**
23 | * 获取已经完成的文件,如果未完成返回空
24 | *
25 | * @param userFileId
26 | * @return
27 | */
28 | public UserFile getUserFileComplete(String userFileId);
29 |
30 | /**
31 | * 创建文件
32 | *
33 | * @param userFileName
34 | * 文件名
35 | * @param userFoldParentId
36 | * 文件夹id一般传空
37 | * @param createUserId
38 | * 谁创建的
39 | * @param fileBaseMd5
40 | * 文件md5码
41 | * @param fileBaseTotalSize
42 | * 文件总大小
43 | * @param fileBase
44 | * 基础文件对象
45 | * @return
46 | */
47 | public UserFile createUserFile(String userFileName, String userFoldParentId, String createUserId, String fileBaseMd5, long fileBaseTotalSize, FileBase fileBase);
48 |
49 | /**
50 | * 改变文件指向
51 | *
52 | * @param userFile
53 | * @param fileBase
54 | * @return
55 | */
56 | public boolean changeFileBase(UserFile userFile, FileBase fileBase);
57 |
58 | /**
59 | * 创建一个存储地址
60 | */
61 | public void createFileBaseDir();
62 |
63 | /**
64 | * 获取真实文件
65 | *
66 | * @param fileBaseRealPath
67 | * @return
68 | */
69 | public File getFile(String fileBaseRealPath);
70 |
71 | /**
72 | * 写入文件块
73 | *
74 | * @param file
75 | * @param chunkFile
76 | * @return
77 | */
78 | public boolean updateFile(File file, File chunkFile);
79 |
80 | /**
81 | * 更新filebase
82 | *
83 | * @param userFile
84 | * @param uploadLength
85 | * @return
86 | */
87 | public boolean updateUserFile(UserFile userFile, int uploadLength);
88 | }
89 |
--------------------------------------------------------------------------------
/AnyUploadServer/src/main/java/org/anyupload/MyAppender.java:
--------------------------------------------------------------------------------
1 | package org.anyupload;
2 |
3 | import org.apache.log4j.DailyRollingFileAppender;
4 | import org.apache.log4j.Priority;
5 |
6 | public class MyAppender extends DailyRollingFileAppender {
7 | @Override
8 | public boolean isAsSevereAsThreshold(Priority priority) {
9 | return this.getThreshold().equals(priority);
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/AnyUploadServer/src/main/java/org/anyupload/UploadService.java:
--------------------------------------------------------------------------------
1 | package org.anyupload;
2 |
3 | import java.io.File;
4 | import java.util.Date;
5 | import java.util.HashMap;
6 | import java.util.Map;
7 |
8 | import org.anyupload.protobuf.ErrorProto.ErrorCode;
9 | import org.anyupload.protobuf.ErrorProto.ErrorS;
10 | import org.anyupload.protobuf.UploadFileProto.MD5CheckC;
11 | import org.anyupload.protobuf.UploadFileProto.MD5CheckS;
12 | import org.anyupload.protobuf.UploadFileProto.UploadFileC;
13 | import org.anyupload.protobuf.UploadFileProto.UploadFileS;
14 | import org.grain.httpserver.FileData;
15 | import org.grain.httpserver.HttpException;
16 | import org.grain.httpserver.HttpPacket;
17 | import org.grain.httpserver.IHttpListener;
18 |
19 | public class UploadService implements IHttpListener {
20 | public IUserFileAction userFileAction;
21 |
22 | @Override
23 | public Map getHttps() {
24 | HashMap map = new HashMap<>();
25 | map.put(HOpCode.MD5_CHECK, "md5CheckHandle");
26 | map.put(HOpCode.UPLOAD_FILE, "uploadFileHandle");
27 | return map;
28 | }
29 |
30 | public HttpPacket md5CheckHandle(HttpPacket httpPacket) throws HttpException {
31 | MD5CheckC message = (MD5CheckC) httpPacket.getData();
32 | UserFile userFile = null;
33 | // 不为空
34 | if (message.getUserFileId() != null && !message.getUserFileId().equals("")) {
35 | // 获取文件
36 | userFile = userFileAction.getUserFile(message.getUserFileId());
37 | // 如果已经完成,秒传
38 | if (userFile != null && userFile.getFileBase().getFileBaseState() == FileBaseConfig.STATE_COMPLETE) {
39 | MD5CheckS.Builder builder = MD5CheckS.newBuilder();
40 | builder.setHOpCode(httpPacket.gethOpCode());
41 | builder.setResult(1);
42 | builder.setUserFileId(userFile.getUserFileId());
43 | HttpPacket packet = new HttpPacket(httpPacket.gethOpCode(), builder.build());
44 | return packet;
45 | }
46 | }
47 | // 取已经完成的基础文件
48 | FileBase fileBase = userFileAction.getFileBaseByMd5(message.getFileBaseMd5());
49 | if (userFile == null) {
50 | // 文件为空,则创建文件
51 | userFile = userFileAction.createUserFile(message.getUserFileName(), message.getUserFoldParentId(), null, message.getFileBaseMd5(), message.getFileBaseTotalSize(), fileBase);
52 | if (userFile == null) {
53 | ErrorS boxErrorS = createError(ErrorCode.ERROR_CODE_0, httpPacket.gethOpCode());
54 | throw new HttpException(HOpCode.ERROR, boxErrorS);
55 | }
56 | if (fileBase != null) {
57 | // 秒传
58 | MD5CheckS.Builder builder = MD5CheckS.newBuilder();
59 | builder.setHOpCode(httpPacket.gethOpCode());
60 | builder.setResult(1);
61 | builder.setUserFileId(userFile.getUserFileId());
62 | HttpPacket packet = new HttpPacket(httpPacket.gethOpCode(), builder.build());
63 | return packet;
64 | } else {
65 | // 通知从哪开始传
66 | MD5CheckS.Builder builder = MD5CheckS.newBuilder();
67 | builder.setHOpCode(httpPacket.gethOpCode());
68 | builder.setResult(2);
69 | builder.setUserFileId(userFile.getUserFileId());
70 | builder.setFileBasePos(userFile.getFileBase().getFileBasePos());
71 | builder.setUploadMaxLength(CommonConfig.UPLOAD_MAX_LENGTH);
72 | HttpPacket packet = new HttpPacket(httpPacket.gethOpCode(), builder.build());
73 | return packet;
74 | }
75 | } else {
76 | if (fileBase != null) {
77 | // 更新,然后秒传
78 | boolean result = userFileAction.changeFileBase(userFile, fileBase);
79 | if (!result) {
80 | ErrorS boxErrorS = createError(ErrorCode.ERROR_CODE_0, httpPacket.gethOpCode());
81 | throw new HttpException(HOpCode.ERROR, boxErrorS);
82 | }
83 | MD5CheckS.Builder builder = MD5CheckS.newBuilder();
84 | builder.setHOpCode(httpPacket.gethOpCode());
85 | builder.setResult(1);
86 | builder.setUserFileId(userFile.getUserFileId());
87 | HttpPacket packet = new HttpPacket(httpPacket.gethOpCode(), builder.build());
88 | return packet;
89 | } else {
90 | // 通知从哪开始传
91 | MD5CheckS.Builder builder = MD5CheckS.newBuilder();
92 | builder.setHOpCode(httpPacket.gethOpCode());
93 | builder.setResult(2);
94 | builder.setUserFileId(userFile.getUserFileId());
95 | builder.setFileBasePos(userFile.getFileBase().getFileBasePos());
96 | builder.setUploadMaxLength(CommonConfig.UPLOAD_MAX_LENGTH);
97 | HttpPacket packet = new HttpPacket(httpPacket.gethOpCode(), builder.build());
98 | return packet;
99 | }
100 | }
101 | }
102 |
103 | public HttpPacket uploadFileHandle(HttpPacket httpPacket) throws HttpException {
104 | UploadFileC message = (UploadFileC) httpPacket.getData();
105 | UserFile userFile = userFileAction.getUserFile(message.getUserFileId());
106 | if (userFile == null) {
107 | ErrorS boxErrorS = createError(ErrorCode.ERROR_CODE_1, httpPacket.gethOpCode());
108 | throw new HttpException(HOpCode.ERROR, boxErrorS);
109 | }
110 | // 位置不对
111 | if (message.getFileBasePos() != userFile.getFileBase().getFileBasePos()) {
112 | ErrorS boxErrorS = createError(ErrorCode.ERROR_CODE_2, httpPacket.gethOpCode());
113 | throw new HttpException(HOpCode.ERROR, boxErrorS);
114 | }
115 | // 不能大于默认长度
116 | if (message.getUploadLength() > CommonConfig.UPLOAD_MAX_LENGTH) {
117 | ErrorS boxErrorS = createError(ErrorCode.ERROR_CODE_3, httpPacket.gethOpCode());
118 | throw new HttpException(HOpCode.ERROR, boxErrorS);
119 | }
120 | // 没有文件
121 | if (httpPacket.fileList == null || httpPacket.fileList.size() == 0) {
122 | ErrorS boxErrorS = createError(ErrorCode.ERROR_CODE_4, httpPacket.gethOpCode());
123 | throw new HttpException(HOpCode.ERROR, boxErrorS);
124 | }
125 | FileData fileData = httpPacket.fileList.get(0);
126 | // 文件长度与消息长度不符
127 | if ((int) fileData.getFile().length() != message.getUploadLength()) {
128 | ErrorS boxErrorS = createError(ErrorCode.ERROR_CODE_3, httpPacket.gethOpCode());
129 | throw new HttpException(HOpCode.ERROR, boxErrorS);
130 | }
131 | // 不存在这个文件
132 | File file = userFileAction.getFile(userFile.getFileBase().getFileBaseRealPath());
133 | if (file == null) {
134 | ErrorS boxErrorS = createError(ErrorCode.ERROR_CODE_5, httpPacket.gethOpCode());
135 | throw new HttpException(HOpCode.ERROR, boxErrorS);
136 | }
137 | if (file.length() != message.getFileBasePos()) {
138 | ErrorS boxErrorS = createError(ErrorCode.ERROR_CODE_3, httpPacket.gethOpCode());
139 | throw new HttpException(HOpCode.ERROR, boxErrorS);
140 | }
141 | Date date = new Date();
142 | // 是否在规定时间后上传
143 | if (date.getTime() < userFile.getFileBase().getFileBaseNextUploadTime().getTime()) {
144 | ErrorS boxErrorS = createError(ErrorCode.ERROR_CODE_6, httpPacket.gethOpCode());
145 | throw new HttpException(HOpCode.ERROR, boxErrorS);
146 | }
147 | FileBase fileBase = userFileAction.getFileBaseByMd5(userFile.getFileBase().getFileBaseMd5());
148 | if (fileBase != null) {
149 | // 更新,然后秒传
150 | boolean result = userFileAction.changeFileBase(userFile, fileBase);
151 | if (!result) {
152 | ErrorS boxErrorS = createError(ErrorCode.ERROR_CODE_7, httpPacket.gethOpCode());
153 | throw new HttpException(HOpCode.ERROR, boxErrorS);
154 | }
155 | UploadFileS.Builder builder = UploadFileS.newBuilder();
156 | builder.setHOpCode(httpPacket.gethOpCode());
157 | builder.setResult(1);
158 | builder.setUserFileId(userFile.getUserFileId());
159 | HttpPacket packet = new HttpPacket(httpPacket.gethOpCode(), builder.build());
160 | return packet;
161 | }
162 | boolean result = userFileAction.updateFile(file, fileData.getFile());
163 | if (!result) {
164 | ErrorS boxErrorS = createError(ErrorCode.ERROR_CODE_8, httpPacket.gethOpCode());
165 | throw new HttpException(HOpCode.ERROR, boxErrorS);
166 | }
167 | result = userFileAction.updateUserFile(userFile, message.getUploadLength());
168 | if (!result) {
169 | ErrorS boxErrorS = createError(ErrorCode.ERROR_CODE_9, httpPacket.gethOpCode());
170 | throw new HttpException(HOpCode.ERROR, boxErrorS);
171 | }
172 | if ((message.getFileBasePos() + message.getUploadLength()) == userFile.getFileBase().getFileBaseTotalSize()) {
173 | UploadFileS.Builder builder = UploadFileS.newBuilder();
174 | builder.setHOpCode(httpPacket.gethOpCode());
175 | builder.setResult(3);
176 | builder.setUserFileId(userFile.getUserFileId());
177 | HttpPacket packet = new HttpPacket(httpPacket.gethOpCode(), builder.build());
178 | return packet;
179 | } else {
180 | UploadFileS.Builder builder = UploadFileS.newBuilder();
181 | builder.setHOpCode(httpPacket.gethOpCode());
182 | builder.setResult(2);
183 | builder.setUserFileId(userFile.getUserFileId());
184 | builder.setWaitTime(CommonConfig.WAIT_TIME);
185 | builder.setUploadMaxLength(CommonConfig.UPLOAD_MAX_LENGTH);
186 | builder.setFileBasePos((message.getFileBasePos() + message.getUploadLength()));
187 | HttpPacket packet = new HttpPacket(httpPacket.gethOpCode(), builder.build());
188 | return packet;
189 | }
190 | }
191 |
192 | public UploadService() {
193 | userFileAction = new UserFileAction();
194 | userFileAction.createFileBaseDir();
195 | }
196 |
197 | public static ErrorS createError(ErrorCode boxErrorCode, String errorHOpCode) {
198 | ErrorS.Builder errorBuilder = ErrorS.newBuilder();
199 | errorBuilder.setHOpCode(HOpCode.ERROR);
200 | errorBuilder.setErrorCode(boxErrorCode);
201 | errorBuilder.setErrorHOpCode(errorHOpCode);
202 | return errorBuilder.build();
203 | }
204 | }
205 |
--------------------------------------------------------------------------------
/AnyUploadServer/src/main/java/org/anyupload/UserFile.java:
--------------------------------------------------------------------------------
1 | package org.anyupload;
2 |
3 | import java.util.Date;
4 |
5 | public class UserFile {
6 | /**
7 | * uuid
8 | */
9 | private String userFileId;
10 | /**
11 | * 文件名
12 | */
13 | private String userFileName;
14 | /**
15 | * 父类文件夹(没用)
16 | */
17 | private String userFoldParentId;
18 | /**
19 | * 创建时间
20 | */
21 | private Date userFileCreateTime;
22 | /**
23 | * 更新时间
24 | */
25 | private Date userFileUpdateTime;
26 | /**
27 | * 文件状态(没用)
28 | */
29 | private int userFileState;
30 | /**
31 | * 顶级文件夹id(没用)
32 | */
33 | private String userFoldTopId;
34 | /**
35 | * 创建者(没用)
36 | */
37 | private String createUserId;
38 | /**
39 | * 基础文件id(没用)
40 | */
41 | private String fileBaseId;
42 | /**
43 | * 基础文件对象
44 | */
45 | private FileBase fileBase;
46 |
47 | public String getUserFileId() {
48 | return userFileId;
49 | }
50 |
51 | public void setUserFileId(String userFileId) {
52 | this.userFileId = userFileId;
53 | }
54 |
55 | public String getUserFileName() {
56 | return userFileName;
57 | }
58 |
59 | public void setUserFileName(String userFileName) {
60 | this.userFileName = userFileName;
61 | }
62 |
63 | public String getUserFoldParentId() {
64 | return userFoldParentId;
65 | }
66 |
67 | public void setUserFoldParentId(String userFoldParentId) {
68 | this.userFoldParentId = userFoldParentId;
69 | }
70 |
71 | public Date getUserFileCreateTime() {
72 | return userFileCreateTime;
73 | }
74 |
75 | public void setUserFileCreateTime(Date userFileCreateTime) {
76 | this.userFileCreateTime = userFileCreateTime;
77 | }
78 |
79 | public Date getUserFileUpdateTime() {
80 | return userFileUpdateTime;
81 | }
82 |
83 | public void setUserFileUpdateTime(Date userFileUpdateTime) {
84 | this.userFileUpdateTime = userFileUpdateTime;
85 | }
86 |
87 | public int getUserFileState() {
88 | return userFileState;
89 | }
90 |
91 | public void setUserFileState(int userFileState) {
92 | this.userFileState = userFileState;
93 | }
94 |
95 | public String getUserFoldTopId() {
96 | return userFoldTopId;
97 | }
98 |
99 | public void setUserFoldTopId(String userFoldTopId) {
100 | this.userFoldTopId = userFoldTopId;
101 | }
102 |
103 | public String getCreateUserId() {
104 | return createUserId;
105 | }
106 |
107 | public void setCreateUserId(String createUserId) {
108 | this.createUserId = createUserId;
109 | }
110 |
111 | public String getFileBaseId() {
112 | return fileBaseId;
113 | }
114 |
115 | public void setFileBaseId(String fileBaseId) {
116 | this.fileBaseId = fileBaseId;
117 | }
118 |
119 | public FileBase getFileBase() {
120 | return fileBase;
121 | }
122 |
123 | public void setFileBase(FileBase fileBase) {
124 | this.fileBase = fileBase;
125 | }
126 |
127 | }
128 |
--------------------------------------------------------------------------------
/AnyUploadServer/src/main/java/org/anyupload/UserFileAction.java:
--------------------------------------------------------------------------------
1 | package org.anyupload;
2 |
3 | import java.io.File;
4 | import java.io.FileInputStream;
5 | import java.io.FileOutputStream;
6 | import java.io.IOException;
7 | import java.text.SimpleDateFormat;
8 | import java.util.Date;
9 | import java.util.Map;
10 | import java.util.UUID;
11 | import java.util.concurrent.ConcurrentHashMap;
12 |
13 | import org.grain.httpserver.HttpConfig;
14 |
15 | public class UserFileAction implements IUserFileAction {
16 | public static String FILE_BASE_PATH;
17 | public static SimpleDateFormat shortDateFormat = new SimpleDateFormat("yyyy-MM-dd");
18 | /**
19 | * 文件map uuid->UserFile
20 | */
21 | public static Map userFileMap = new ConcurrentHashMap();
22 | /**
23 | * 已经上传完成的文件map md5->FileBase
24 | */
25 | public static Map completeFileBaseMap = new ConcurrentHashMap();
26 |
27 | public static boolean stringIsNull(String str) {
28 | if (str == null || str.equals("")) {
29 | return true;
30 | }
31 | return false;
32 | }
33 |
34 | @Override
35 | public FileBase getFileBaseByMd5(String fileBaseMd5) {
36 | if (stringIsNull(fileBaseMd5)) {
37 | return null;
38 | }
39 | return completeFileBaseMap.get(fileBaseMd5);
40 | }
41 |
42 | public static String dateToStringDay(Date date) {
43 | if (date == null) {
44 | return null;
45 | }
46 | return shortDateFormat.format(date);
47 | }
48 |
49 | @Override
50 | public UserFile getUserFile(String userFileId) {
51 | if (stringIsNull(userFileId)) {
52 | return null;
53 | }
54 | return userFileMap.get(userFileId);
55 | }
56 |
57 | @Override
58 | public UserFile getUserFileComplete(String userFileId) {
59 | if (stringIsNull(userFileId)) {
60 | return null;
61 | }
62 | UserFile userFile = userFileMap.get(userFileId);
63 | if (userFile != null) {
64 | if (userFile.getFileBase().getFileBaseState() == FileBaseConfig.STATE_COMPLETE) {
65 | return userFile;
66 | }
67 | }
68 | return null;
69 | }
70 |
71 | @Override
72 | public UserFile createUserFile(String userFileName, String userFoldParentId, String createUserId, String fileBaseMd5, long fileBaseTotalSize, FileBase fileBase) {
73 | if (stringIsNull(userFileName) || stringIsNull(fileBaseMd5)) {
74 | return null;
75 | }
76 | UserFile userFile = new UserFile();
77 | Date date = new Date();
78 | userFile.setUserFileId(UUID.randomUUID().toString().trim().replaceAll("-", ""));
79 | userFile.setUserFileName(userFileName);
80 | userFile.setUserFoldParentId(userFoldParentId);
81 | userFile.setUserFileCreateTime(date);
82 | userFile.setUserFileUpdateTime(date);
83 | userFile.setUserFileState(1);
84 | userFile.setCreateUserId(createUserId);
85 | if (fileBase == null) {
86 | FileBase newFileBase = new FileBase();
87 | newFileBase.setFileBaseId(UUID.randomUUID().toString().trim().replaceAll("-", ""));
88 | String fileBaseRealPath = createFile(getFileName(userFileName, newFileBase.getFileBaseId()));
89 | if (fileBaseRealPath == null) {
90 | return null;
91 | }
92 | newFileBase.setFileBaseRealPath(fileBaseRealPath);
93 | newFileBase.setFileBaseMd5(fileBaseMd5);
94 | newFileBase.setFileBaseState(FileBaseConfig.STATE_UPLOADING);
95 | newFileBase.setFileBaseTotalSize(fileBaseTotalSize);
96 | newFileBase.setFileBasePos(0L);
97 | newFileBase.setFileBaseCreateTime(date);
98 | newFileBase.setFileBaseNextUploadTime(date);
99 | userFile.setFileBaseId(newFileBase.getFileBaseId());
100 | userFile.setFileBase(newFileBase);
101 | } else {
102 | userFile.setFileBaseId(fileBase.getFileBaseId());
103 | userFile.setFileBase(fileBase);
104 | }
105 | userFileMap.put(userFile.getUserFileId(), userFile);
106 | return userFile;
107 | }
108 |
109 | @Override
110 | public boolean changeFileBase(UserFile userFile, FileBase fileBase) {
111 | userFile.setFileBaseId(fileBase.getFileBaseId());
112 | userFile.setFileBase(fileBase);
113 | return true;
114 | }
115 |
116 | @Override
117 | public boolean updateFile(File file, File chunkFile) {
118 | FileOutputStream fileOutputStream = null;
119 | FileInputStream fileInputStream = null;
120 | try {
121 | fileOutputStream = new FileOutputStream(file, true);
122 | fileInputStream = new FileInputStream(chunkFile);
123 | byte[] buffer = new byte[CommonConfig.ONCE_WRITE_FILE_SIZE];
124 | int bytesRead = -1;
125 | while ((bytesRead = fileInputStream.read(buffer)) != -1) {
126 | fileOutputStream.write(buffer, 0, bytesRead);
127 | }
128 | fileOutputStream.flush();
129 | return true;
130 | } catch (Exception e) {
131 | HttpConfig.log.error("修改文件失败", e);
132 | return false;
133 | } finally {
134 | if (fileInputStream != null) {
135 | try {
136 | fileInputStream.close();
137 | } catch (IOException e) {
138 | HttpConfig.log.error("关闭块文件输入流失败", e);
139 | }
140 | }
141 | if (fileOutputStream != null) {
142 | try {
143 | fileOutputStream.close();
144 | } catch (IOException e) {
145 | HttpConfig.log.error("关闭输出流失败", e);
146 | }
147 | }
148 | }
149 | }
150 |
151 | @Override
152 | public boolean updateUserFile(UserFile userFile, int uploadLength) {
153 | Date date = new Date();
154 | userFile.getFileBase().setFileBasePos(userFile.getFileBase().getFileBasePos() + uploadLength);
155 | // 已完成
156 | if (userFile.getFileBase().getFileBasePos() == userFile.getFileBase().getFileBaseTotalSize()) {
157 | userFile.getFileBase().setFileBaseNextUploadTime(null);
158 | userFile.getFileBase().setFileBaseCompleteTime(date);
159 | userFile.getFileBase().setFileBaseState((byte) FileBaseConfig.STATE_COMPLETE);
160 | // 存入md5映射表
161 | completeFileBaseMap.put(userFile.getFileBase().getFileBaseMd5(), userFile.getFileBase());
162 | } else {
163 | long fileBaseNextUploadTimeLong = date.getTime() + CommonConfig.WAIT_TIME;
164 | Date fileBaseNextUploadTime = new Date(fileBaseNextUploadTimeLong);
165 | userFile.getFileBase().setFileBaseNextUploadTime(fileBaseNextUploadTime);
166 | }
167 | return true;
168 | }
169 |
170 | @Override
171 | public void createFileBaseDir() {
172 | FILE_BASE_PATH = HttpConfig.PROJECT_PATH + "/" + CommonConfig.FILE_BASE_PATH;
173 | File file = new File(FILE_BASE_PATH);
174 | if (!file.exists()) {
175 | file.mkdirs();
176 | }
177 | }
178 |
179 | public static String getFileName(String userFileName, String fileBaseId) {
180 | int postfixIndex = userFileName.lastIndexOf(".");
181 | if (postfixIndex == -1) {
182 | return fileBaseId;
183 | } else {
184 | String postfix = userFileName.substring(postfixIndex);
185 | return fileBaseId + postfix;
186 | }
187 | }
188 |
189 | public static String getFoldName() {
190 | Date date = new Date();
191 | String foldName = dateToStringDay(date);
192 | return foldName;
193 | }
194 |
195 | public static String createFile(String fileName) {
196 | String foldName = getFoldName();
197 | boolean result = createFold(foldName);
198 | if (!result) {
199 | return null;
200 | }
201 | File file = new File(FILE_BASE_PATH + "/" + foldName + "/" + fileName);
202 | try {
203 | result = file.createNewFile();
204 | if (result) {
205 | return foldName + "/" + fileName;
206 | } else {
207 | return null;
208 | }
209 | } catch (IOException e) {
210 | HttpConfig.log.error("创建文件异常", e);
211 | return null;
212 | }
213 | }
214 |
215 | @Override
216 | public File getFile(String fileBaseRealPath) {
217 | File file = new File(FILE_BASE_PATH + "/" + fileBaseRealPath);
218 | if (file.exists()) {
219 | return file;
220 | } else {
221 | return null;
222 | }
223 | }
224 |
225 | public static boolean deleteFile(String fileBaseRealPath) {
226 | File file = new File(FILE_BASE_PATH + "/" + fileBaseRealPath);
227 | try {
228 | return file.delete();
229 | } catch (Exception e) {
230 | HttpConfig.log.error("删除文件异常", e);
231 | return false;
232 | }
233 | }
234 |
235 | public static boolean createFold(String name) {
236 | File file = new File(FILE_BASE_PATH + "/" + name);
237 | try {
238 | if (!file.exists()) {
239 | file.mkdirs();
240 | }
241 | return true;
242 | } catch (Exception e) {
243 | HttpConfig.log.error("创建文件夹异常", e);
244 | return false;
245 | }
246 | }
247 | }
248 |
--------------------------------------------------------------------------------
/AnyUploadServer/src/test/java/org/anyupload/Test.java:
--------------------------------------------------------------------------------
1 | package org.anyupload;
2 |
3 | import static org.junit.Assert.*;
4 |
5 | public class Test {
6 |
7 | @org.junit.Test
8 | public void test() {
9 | fail("Not yet implemented");
10 | }
11 |
12 | }
13 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2017 电霸儿
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # anyupload
2 |
3 | [](https://travis-ci.org/dianbaer/anyupload)
4 | [](https://www.codacy.com/app/232365732/anyupload?utm_source=github.com&utm_medium=referral&utm_content=dianbaer/anyupload&utm_campaign=Badge_Grade)
5 | [](LICENSE)
6 |
7 |
8 | ### anyupload是一个极度纯净的上传插件,通过简单调整就可以融入到任何项目,支持多文件上传、上传速率动态控制、真实进度监控kb/s、分块生成MD5、分块上传、MD5校验秒传、暂停、取消等。
9 |
10 |
11 |
12 | ### 体验地址:
13 |
14 | https://www.dianbaer.com/AnyUploadClient/
15 |
16 |
17 | 
18 |
19 |
20 | 
21 |
22 |
23 | ## 项目目录结构:
24 |
25 |
26 | ### AnyUploadClient(1000行代码)
27 |
28 | |--js(js库)
29 | |--anyupload(anyupload文件夹)
30 | |--css(anyupload css)
31 | |--dist(anyupload js打包版本)
32 | |--images(anyupload image)
33 | |--src(anyupload js未打包版本)
34 | |--FileConfig.js(配置)
35 | |--lib(依赖js)
36 | |--jquery.min.js
37 | ######################################
38 | |--juggle-all.js(解耦合的工具库ALL IN ONE:https://github.com/dianbaer/juggle)
39 | 或
40 | |--juggle-help.js
41 | |--juggle-event.js
42 | |--juggle-juggler.js (解耦合的工具库small require:https://github.com/dianbaer/juggle)
43 | |--juggle-http.js
44 | |--juggle-mv.js
45 | ######################################
46 | |--spark-md5.js(用于分块计算md5)
47 | |--index.html(示例启动项目)
48 |
49 |
50 | ### AnyUploadServer(899行代码)
51 |
52 | |--src(服务器代码)
53 | |--CommonConfig.java(配置)
54 | |--protobuf(消息包生成工具)
55 |
56 |
57 | ### AnyUploadClient怎么使用:
58 |
59 | ```html
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
113 |
114 |
115 |
117 |
118 |
119 |
120 |
121 |
122 |
123 | ```
124 |
125 | ### AnyUploadClient js源码打包
126 |
127 |
128 | cd AnyUploadClient/js/anyupload
129 |
130 | npm install -g grunt-cli
131 |
132 | npm install
133 |
134 | grunt
135 |
136 |
137 |
138 | ### AnyUploadServer怎么使用
139 |
140 | 如果测试,直接启动AnyUploadServer即可,不需要修改配置
141 |
142 | 如果融入其他项目,按照AnyUploadServer代码示例需要提供两个接口
143 |
144 | message MD5CheckC{
145 | string hOpCode=1;
146 | string fileBaseMd5=2;//md5
147 | string userFileName=3;//文件名
148 | string userFoldParentId=4;//父类文件夹id
149 | int64 fileBaseTotalSize=5;//文件总大小
150 | string userFileId=6;//文件id
151 | }
152 | message MD5CheckS{
153 | string hOpCode=1;
154 | int32 result=2;//结果1:秒传,2:可以上传
155 | int64 fileBasePos=3;//开始位置
156 | int32 uploadMaxLength=4;//一次上传最大长度
157 | string userFileId=5;//文件id
158 | }
159 | message UploadFileC{
160 | string hOpCode=1;
161 | string userFileId=2;//文件id
162 | int64 fileBasePos=3;//开始位置
163 | int32 uploadLength=4;//上传的长度
164 | }
165 | message UploadFileS{
166 | string hOpCode=1;
167 | int32 result=2;//结果1:秒传,2:可以上传,3上传完成
168 | int64 fileBasePos=3;//开始位置
169 | int32 uploadMaxLength=4;//一次上传最大长度
170 | string userFileId=5;//文件id
171 | int32 waitTime=6;//等待时间
172 | }
173 |
174 | ### AnyUploadServer打包
175 |
176 |
177 | ant
178 |
179 |
180 |
181 |
182 | ### java服务器基于grain
183 |
184 | 依赖以下库,共(1429行,学习成本极低)
185 |
186 | grain-httpserver.jar(1318行)
187 | grain-log.jar(111行)
188 |
189 |
190 | github:
191 |
192 |
193 | https://github.com/dianbaer/grain
194 |
195 |
196 | 码云:
197 |
198 |
199 | https://gitee.com/dianbaer/grain
200 |
201 |
202 | ### js客户端基于juggle
203 |
204 | 最精简依赖以下库,共(614行,学习成本极低)
205 |
206 | juggle-help.js(33行)
207 | juggle-event.js(256行)
208 | juggle-http.js(99行)
209 | juggle-mv.js(104行)
210 | juggle-juggler.js(122行)
211 |
212 | github:
213 |
214 |
215 | https://github.com/dianbaer/juggle
216 |
217 |
218 | 码云:
219 |
220 |
221 | https://gitee.com/dianbaer/basic
222 |
223 |
224 |
--------------------------------------------------------------------------------
/anyupload.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dianbaer/anyupload/6078d0b7626b9672df08c012b9d2946326a7f0b1/anyupload.png
--------------------------------------------------------------------------------
/anyuploadflow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dianbaer/anyupload/6078d0b7626b9672df08c012b9d2946326a7f0b1/anyuploadflow.png
--------------------------------------------------------------------------------
/anyuploadflow.pptx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dianbaer/anyupload/6078d0b7626b9672df08c012b9d2946326a7f0b1/anyuploadflow.pptx
--------------------------------------------------------------------------------
/build.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------