*摘自博客园:原文链接(点击跳转)
function upload_oss(file, all_file, accessKeyId, accessKeySecret, bucket, layer){
// 创建客户端
var client = new OSS.Wrapper({
region: 'oss-cn-beijing',//你的oss地址 ,具体位置见下图
accessKeyId: accessKeyId,//你的ak
accessKeySecret: accessKeySecret,//你的secret
bucket: bucket//你的oss buct名字
});
console.log(all_file)
// 开始上传, all_file 是在oss 的 路径 + 文件名 , file 是文件
client.multipartUpload( all_file, file).then(function (result) {
console.log(result)
layer.msg("上传成功", function(){
layer.closeAll();
window.location.reload();
})
}).catch(function (err) {
console.log(err)
layer.msg("上传失败", function(){
layer.closeAll();
})
});
};