irc_web/.svn/pristine/9c/9c5aa83da8e623c30dffb4ff7c3...

29 lines
831 B
Plaintext

const OSS = require('ali-oss')
import Vue from 'vue'
const { GenerateSTS, GetObjectStoreToken } = require('../api/user.js')
import { getToken } from '@/utils/auth'
Vue.prototype.OSSclientConfig = {
}
async function ossGenerateSTS() {
let res = await GetObjectStoreToken()
Vue.prototype.OSSclientConfig = { ...res.Result[res.Result.ObjectStoreUse] }
Vue.prototype.OSSclientConfig.basePath = Vue.prototype.OSSclientConfig.ViewEndpoint
switch (res.Result.ObjectStoreUse) {
case 'AliyunOSS':
Vue.prototype.OSSclientConfig.bucket = Vue.prototype.OSSclientConfig.bucketName
Vue.prototype.OSSclient = new OSS(Vue.prototype.OSSclientConfig)
break
case 'MinIO':
Vue.prototype.OSSclient = new OSS(Vue.prototype.OSSclientConfig)
break
}
return
}
export const OSSclient = ossGenerateSTS