Skip to content

Commit

Permalink
update pre code
Browse files Browse the repository at this point in the history
  • Loading branch information
SunLn committed Feb 26, 2014
1 parent 37163ca commit 06552bd
Showing 1 changed file with 43 additions and 33 deletions.
76 changes: 43 additions & 33 deletions example/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -94,42 +94,52 @@ <h4 class="modal-title" id="myModalLabel">查看初始化代码</h4>
<pre><code>
//引入Plupload 、qiniu.js后

var Q = new Qiniu({
runtimes: 'html5,flash,html4', //上传方式,依次退化
browse_button: 'pickfiles', //上传选择的点选按钮,必须
uptoken_url: '/token', //请求uptoken的Url,必须
domain: 'http://qiniu-plupload.qiniudn.com/',//buckete 域名,下载资源时用到,必须
container: 'container',//上传区域DOM ID,默认是browser_button的父元素,
drop_element: 'container', //拖曳上传区域元素的ID
max_file_size: '100mb', //最大文件体积限制
flash_swf_url: 'js/plupload/Moxie.swf',//引入flash
max_retries: 3,//上传失败最大重试次数
dragdrop: true, //开启可拖曳上传
chunk_size: '4mb',//分片上传时,每片的体积
auto_start: true, //选择文件后自动上传,若关闭需要自己绑定事件触发上传
init: {
'FilesAdded': function(up, files) {
plupload.each(files, function(file) {
//文件添加进队列后,处理相关的事情
});
},
'BeforeUpload': function(up, file) {
var Q = new Qiniu({
runtimes: 'html5,flash,html4', //上传模式,依次退化
browse_button: 'pickfiles', //上传选择的点选按钮,**必须**
uptoken_url: '/token', //Ajax请求upToken的Url,**必须**(服务端提供)
domain: 'http://qiniu-plupload.qiniudn.com/', //buckete 域名,下载资源时用到,**必须**
container: 'container', //上传区域DOM ID,默认是browser_button的父元素,
max_file_size: '100mb', //最大文件体积限制
flash_swf_url: 'js/plupload/Moxie.swf', //引入flash,相对路径
max_retries: 3, //上传失败最大重试次数
dragdrop: true, //开启可拖曳上传
drop_element: 'container', //拖曳上传区域元素的ID,拖曳文件或文件夹后可触发上传
chunk_size: '4mb', //分块上传时,每片的体积
auto_start: true, //选择文件后自动上传,若关闭需要自己绑定事件触发上传
init: {
'FilesAdded': function(up, files) {
plupload.each(files, function(file) {
//文件添加进队列后,处理相关的事情
});
},
'BeforeUpload': function(up, file) {
//每个文件上传前,处理相关的事情
},
'UploadProgress': function(up, file) {
//每个文件上传时,处理相关的事情
},
'FileUploaded': function(up, file, info) {
},
'UploadProgress': function(up, file) {
//每个文件上传时,处理相关的事情
},
'FileUploaded': function(up, file, info) {
//每个文件上传成功后,处理相关的事情
},
'Error': function(up, err, errTip) {
//上传出错时,处理相关的事情
},
'UploadComplete': function() {
//队列文件处理完毕后,处理相关的事情
}
//其中 info 是文件上传成功后,服务端返回的json,形式如
// {
// "hash": "Fh8xVqod2MQ1mocfI4S4KpRL6D98",
// "key": "gogopher.jpg"
// }
// 参考http://developer.qiniu.com/docs/v6/api/overview/up/response/simple-response.html

// var domain = up.getOption('domain');
// var res = parseJSON(info);
// var sourceLink = domain + res.key; 获取上传成功后的文件的Url
},
'Error': function(up, err, errTip) {
//上传出错时,处理相关的事情
},
'UploadComplete': function() {
//队列文件处理完毕后,处理相关的事情
}
});
}
});
</code></pre>
</div>
<div class="modal-footer">
Expand Down

0 comments on commit 06552bd

Please sign in to comment.