44 lines
1.6 KiB
Plaintext
44 lines
1.6 KiB
Plaintext
const OSS = require('ali-oss')
|
|
import Vue from 'vue'
|
|
const { GenerateSTS } = require('../api/user.js')
|
|
|
|
|
|
Vue.prototype.OSSclientConfig = {
|
|
}
|
|
|
|
let rOss
|
|
|
|
function timeout () {
|
|
setInterval(async () => {
|
|
let res = await GenerateSTS()
|
|
Vue.prototype.OSSclientConfig.region = res.Result.Region
|
|
Vue.prototype.OSSclientConfig.accessKeyId = res.Result.AccessKeyId
|
|
Vue.prototype.OSSclientConfig.accessKeySecret = res.Result.AccessKeySecret
|
|
Vue.prototype.OSSclientConfig.bucket = res.Result.BucketName
|
|
Vue.prototype.OSSclientConfig.basePath = res.Result.ViewEndpoint
|
|
Vue.prototype.OSSclientConfig.stsToken = res.Result.SecurityToken
|
|
Vue.prototype.OSSclient = new OSS(Vue.prototype.OSSclientConfig)
|
|
console.log('已将OSSclient修改成最新stsToken', Vue.prototype.OSSclientConfig)
|
|
}, 60000 * 10)
|
|
}
|
|
|
|
|
|
async function ossGenerateSTS() {
|
|
let res = await GenerateSTS()
|
|
Vue.prototype.OSSclientConfig.region = res.Result.Region
|
|
// Vue.prototype.OSSclientConfig.accessKeyId = res.Result.AccessKeyId
|
|
Vue.prototype.OSSclientConfig.accessKeyId = 'mpXG7Nu6zTpsDrI1'
|
|
// Vue.prototype.OSSclientConfig.accessKeySecret = res.Result.AccessKeySecret
|
|
Vue.prototype.OSSclientConfig.accessKeySecret = 'yNINcEb099SkNfF6vYKaoP8TZNI3xZ'
|
|
Vue.prototype.OSSclientConfig.bucket = res.Result.BucketName
|
|
Vue.prototype.OSSclientConfig.basePath = res.Result.ViewEndpoint
|
|
Vue.prototype.OSSclientConfig.stsToken = res.Result.SecurityToken
|
|
timeout()
|
|
rOss = new OSS(Vue.prototype.OSSclientConfig)
|
|
return rOss
|
|
}
|
|
|
|
|
|
|
|
export const OSSclient = ossGenerateSTS()
|