30 lines
857 B
Plaintext
30 lines
857 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] }
|
|
console.log(Vue.prototype.OSSclientConfig)
|
|
Vue.prototype.OSSclientConfig.basePath = res.Result.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
|