编写一个使用 SWFUpload 进行多文件上传的 Google Closure Library 组件实际上相当容易。我使用 Closure Compiler 创建了一个用于高级编译的 externs 文件:
var SWFUpload = {
"instances": function () {},
"movieCount": {},
"version": {},
"QUEUE_ERROR": {
"QUEUE_LIMIT_EXCEEDED": {},
"FILE_EXCEEDS_SIZE_LIMIT": {},
"ZERO_BYTE_FILE": {},
"INVALID_FILETYPE": {}
},
"UPLOAD_ERROR": {
"HTTP_ERROR": {},
"MISSING_UPLOAD_URL": {},
"IO_ERROR": {},
"SECURITY_ERROR": {},
"UPLOAD_LIMIT_EXCEEDED": {},
"UPLOAD_FAILED": {},
"SPECIFIED_FILE_ID_NOT_FOUND": {},
"FILE_VALIDATION_FAILED": {},
"FILE_CANCELLED": {},
"UPLOAD_STOPPED": {}
},
"FILE_STATUS": {
"QUEUED": {},
"IN_PROGRESS": {},
"ERROR": {},
"COMPLETE": {},
"CANCELLED": {}
},
"BUTTON_ACTION": {
"SELECT_FILE": {},
"SELECT_FILES": {},
"START_UPLOAD": {},
"JAVASCRIPT": {}
},
"CURSOR": {
"ARROW": {},
"HAND": {}
},
"WINDOW_MODE": {
"WINDOW": {},
"TRANSPARENT": {},
"OPAQUE": {}
},
"completeURL": function () {},
"Console": {
"writeLine": function () {}
}
},
FileProgress = {}