COS Js SDK文档
<script>
const COS = require('cos-js-sdk-v5');
const cosf = new COS({
SecretId: '...',
SecretKey: '...',
});
export default {
methods: {
doputFunc() {
cosf.putObject({
Body: 'file类型的对象或流',
Bucket: '...',
Region: '...',
Key: `...`,
onProgress: function(progressData) {
console.log(progressData)
},
}),function(err, data) {
console.log('function',err || data);
this.getReturnUrl(key)
}
},
docutFunc(){
cosf.uploadFile({
Bucket: '...',
Region: '...',
Key: `...`,
Body: 'file类型的对象或流',
SliceSize: 1024 * 1024 * 5,
onTaskReady: function(taskId) {
console.log('onTaskReady ---->',taskId);
},
onProgress: function (progressData) {
console.log('onProgress ---->',JSON.stringify(progressData));
},
onFileFinish: function (err, data, options) {
this.getReturnUrl()
},
}, function(err, data) {
console.log('function ---->',err || data);
});
},
getReturnUrl(key){
cosf.getObjectUrl({
Bucket: '...',
Region: '...',
Key: `...`,
Sign: false
}, function (err, data) {
})
}
}
}
</script>
|