模块中直接使用的天翼云的官方jssdk+plupload,实现分片上传。
使用简单,直接传天翼云的相关参数进去就行,支持自定义FilesAdded、FileUploaded、ChunkUploaded、BeforeUpload等方法。
layui.config({
base: '__PUBLIC__/layui/' //静态资源所在路径
}).extend({
ctyun: 'ctyun/index',
}).use(['index', 'ctyun'], function(){
var $ = layui.$
,element = layui.element
,layer = layui.layer
,ctyun= layui.ctyun;
ctyun.loader({
endPoint: '{$config.ctyun_domain}'
, browse_button: "upload-video"
, drop_element: "hahaha"
, BucketName: "{$config.ctyun_bucket}"
, accessKeyId: "{$config.ctyun_access_key}"
, secretAccessKey: "{$config.ctyun_secret_key}"
, initial: true
, UploadProgress: function(response){
$(".show_video").show();
$(".layui-progress").hide();
element.progress('video-progress', response.percent + '%');
}
, UploadComplete: function(res){
// layer.closeAll('loading'); // 可以调用loading
layer.msg("上传成功!");
$("#video_url").val(res.Location);
$(".show_video").find("video").attr("src", res.Location);
$(".layui-progress").hide();
}
})
});