NodeJS Websocket Upload, multiple files upload 多文件上传
Server Base Example:
var wsuploader = require('websocket_upload');
wsuploader.init(6999);
Client Base Example:
<script src="/js/websocket_upload_c.js"></script>
websocket_upload_c.connect("127.0.0.1", 6999);
websocket_upload_c.upload(files); // <input type="file" multiple>
Client CallBack Example:
websocket_upload_c.set_callback({
process_cb: (info) => {
console.log("process_cb ", info.pct);
},
complete_cb: (info) => {
console.log("complte_cb ", info);
}
});
Server Auth Example:
wsuploader.set_auth(true, ["client1_auth_code"]);
Client Auth Example:
websocket_upload_c.connect("127.0.0.1", 6999, "client1_auth_code");
客户端回调事件:
auth_cb 验证
info_cb 服务端反馈消息
start_cb 开始上传
process_cb 上传进度
complete_cb 上传完成
服务端端回调事件:
auth_cb 验证
start_cb 开始上传
process_cb 上传进度
complete_cb 上传完成
客户端上传:
upload(files) 文件上传
upload_direct(files, request_info) 根据服务器返回的request info来上传
服务端:
init 初始化
set_auth 设置验证code
findClient 查找客户端
add_auth_code 添加验证
del_auth_code 删除验证
set_callback 设置回调
set_cache_path 设置下载路径
sendMsg 发送消息
addQueues 添加下载队列