Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return new Promise((resolve, reject) => {
const cos = new COS({
getAuthorization: function(options, callback) {
console.log(`options值为${JSON.stringify(options)}`)
// 异步获取签名
get(
`https://download.aijiatui.com/api/Auth/signature?method=${options.Method ||
'GET'}&pathname=${'/' + (options.Key || '')}`, {}, {
withToken: false,
ignoreCode: true
}
)
.then(res => {
const data = res.data
callback(data.signature)
})
.catch(err=>{
console.log(`err值为${JSON.stringify(err)}`)
import config from '../config'
// 初始化实例
import COS from 'cos-js-sdk-v5'
let cos = null
if (config.cos.secretId != null && config.cos.secretId !== '' && config.cos.secretKey != null && config.cos.secretKey !== '') {
cos = new COS({
SecretId: config.cos.secretId,
SecretKey: config.cos.secretKey
})
} else {
cos = new COS({
// 必选参数
getAuthorization (options, callback) { // 不传secretKey代表使用临时签名模式,此时此参数必传(安全,生产环境推荐)
config.cos.getAuthorization(options).then(data => {
// eslint-disable-next-line standard/no-callback-literal
callback(data)
})
}
})
}
export default {
/**
*
* @param parent
* @param file
* @param custom