我用七牛js skd上传文件,却总是报qiniu.js:663 Uncaught TypeError: Cannot read property 'isExpired' of undefined(…)问题出在plupload,js中
z这是我的代码
var uploader = Qiniu.uploader({
runtimes: 'html5,flash,html4',
browse_button: 'pickfiles',
container: 'container',
drop_element: 'container',
max_file_size: '1000mb',
flash_swf_url: 'bower_components/plupload/js/Moxie.swf',
dragdrop: true,
chunk_size: '4mb',
multi_selection: !(mOxie.Env.OS.toLowerCase()==="ios"),
//uptoken_url: $('#uptoken_url').val(),
save_key:false,
unique_names:false,
uptoken_func: function(){
var token;
$.ajax({
url:$('#uptoken_url').val(),
async:false
}).done(function (data) {
token= data.result.data.tokenValue;
});
return token;
},
domain: $('#domain').val(),
get_new_uptoken: true,
// downtoken_url: '/downtoken',
// unique_names: true,
// save_key: true,
// x_vars: {
// 'id': '1234',
// 'time': function(up, file) {
// var time = (new Date()).getTime();
// // do something with 'time'
// return time;
// },
// },
auto_start: true,
log_level: 5,
init: {
'FilesAdded': function(up, files) {
var maxFileSize=1;
if(up.files.length>maxFileSize){
alert("你只能上传一个文件");
up.splice(maxFileSize);
return;
}
$('table').show();
$('#success').hide();
plupload.each(files, function(file) {
var progress = new FileProgress(file, 'fsUploadProgress');
progress.setStatus("等待...");
progress.bindUploadCancel(up);
});
},
'BeforeUpload': function(up, file) {
var progress = new FileProgress(file, 'fsUploadProgress');
var chunk_size = plupload.parseSize(this.getOption('chunk_size'));
if (up.runtime === 'html5' && chunk_size) {
progress.setChunkProgess(chunk_size);
}
},
'UploadProgress': function(up, file) {
var progress = new FileProgress(file, 'fsUploadProgress');
var chunk_size = plupload.parseSize(this.getOption('chunk_size'));
progress.setProgress(file.percent + "%", file.speed, chunk_size);
},
'UploadComplete': function() {
$('#success').show();
},
'FileUploaded': function(up, file, info) {
var progress = new FileProgress(file, 'fsUploadProgress');
progress.setComplete(up, info);
},
'Error': function(up, err, errTip) {
$('table').show();
var progress = new FileProgress(err.file, 'fsUploadProgress');
progress.setError();
progress.setStatus(errTip);
}
}
});
这是我从服务端获取token的方法
public String getToken(Model model){
AjaxResult result=new AjaxResult();
String fileName= UUIDGenerator.getUUID();
QiniuUploadUtils qiniuUploadUtils=new QiniuUploadUtils();
HashMap token=new HashMap();
token.put("tokenValue",qiniuUploadUtils.getToken(fileName));
token.put("file",fileName);
result.setData(token);
model.addAttribute("result",result);
return this.result(ResultType.JSON);
}
是否有公网访问的测试地址?