获取临时密钥 官网SDK 临时秘钥请让后端人员进行给接口进行数据的获取
测试环境用的例子 <–请点击
<script>
const COS = require('cos-js-sdk-v5');
export default {
methods: {
demoFunc(){
let that = this;
let t = 'api返回的数据';
let cosf = new COS({
SecretId: t.tmp_secretId,
SecretKey: t.tmp_secretKey,
SecurityToken: t.session_token
});
cosf.uploadFile({
Bucket: t.Bucket,
Region: t.Region,
Key: '路径/' + e.file.name,
Body: e.file,
SliceSize: 1024 * 1024 * tong.size,
onFileFinish: function (err, data, options) {
cosf.getObjectUrl({
Bucket: t.Bucket,
Region: t.Region,
Key: '路径/' + e.file.name,
Sign: false
}, function (err, data) {
console.log(data.Url)
e.file.status = 'done'
e.onProgress({percent:100})
e.onSuccess()
})
},
}, function(err, data) {
});
}
}
</script>
|