oss兼容aws
parent
31a2b6c6fb
commit
cf4b6887da
22
src/main.js
22
src/main.js
|
@ -96,24 +96,14 @@ Vue.prototype.selectDictLabel = selectDictLabel
|
|||
// Vue.prototype.download = download
|
||||
Vue.prototype.handleTree = handleTree
|
||||
Vue.prototype.$getObjectName = (url) => {
|
||||
// console.log(Vue.prototype.)
|
||||
// console.log(url)
|
||||
var value = url
|
||||
// var str = value.split("//"); //https://进行分割,
|
||||
// var index = str[1].indexOf("/")+1; //indexOf 获取第一个斜杠的索引,
|
||||
// // console.log(str[1].substring(index)); //substring 截取,
|
||||
// return '/' + str[1].substring(index)
|
||||
// console.log(url,'url')
|
||||
// console.log(Vue.prototype.OSSclientConfig.viewEndpoint,'url')
|
||||
var value = url;
|
||||
let basePath = Vue.prototype.OSSclientConfig.viewEndpoint;
|
||||
let basePathHttp = Vue.prototype.OSSclientConfig.viewEndpoint.replace("https", 'http')
|
||||
let arr = value.split(basePath);
|
||||
let name = null;
|
||||
if (arr.length > 1) {
|
||||
name = arr[1];
|
||||
} else {
|
||||
name = value.split(basePathHttp)[1];
|
||||
if (Vue.prototype.OSSclientConfig.ObjectStoreUse === 'AliyunOSS') {
|
||||
basePath = Vue.prototype.OSSclientConfig.endPoint.split('https://').length > 1 ? Vue.prototype.OSSclientConfig.endPoint.split('https://')[1] : Vue.prototype.OSSclientConfig.endPoint;
|
||||
}
|
||||
// console.log(name)
|
||||
return name;
|
||||
return value.split(basePath)[1];
|
||||
}
|
||||
Vue.prototype.getGuid = (text) => {
|
||||
text = md5(text)
|
||||
|
|
|
@ -20,8 +20,8 @@ function blobToBuffer(blob, fileName) {
|
|||
async function ossGenerateSTS() {
|
||||
let res = await GetObjectStoreToken()
|
||||
Vue.prototype.OSSclientConfig = { ...res.Result[res.Result.ObjectStoreUse] }
|
||||
Vue.prototype.OSSclientConfig.ObjectStoreUse = res.Result.ObjectStoreUse;
|
||||
Vue.prototype.OSSclientConfig.basePath = Vue.prototype.OSSclientConfig.viewEndpoint
|
||||
console.log(Vue.prototype.OSSclientConfig.basePath)
|
||||
switch (res.Result.ObjectStoreUse) {
|
||||
case 'AliyunOSS':
|
||||
Vue.prototype.OSSclientConfig.bucket = Vue.prototype.OSSclientConfig.bucketName
|
||||
|
@ -78,7 +78,7 @@ async function ossGenerateSTS() {
|
|||
} else {
|
||||
resolve({
|
||||
name: objectName,
|
||||
url: 'http://www.abc.com' + objectName
|
||||
url: Vue.prototype.OSSclientConfig.viewEndpoint + decodeUtf8(objectName)
|
||||
})
|
||||
}
|
||||
})
|
||||
|
@ -113,9 +113,10 @@ async function ossGenerateSTS() {
|
|||
console.log(err)
|
||||
reject()
|
||||
} else {
|
||||
console.log(objectName);
|
||||
resolve({
|
||||
name: objectName,
|
||||
url: 'http://www.abc.com' + objectName
|
||||
url: Vue.prototype.OSSclientConfig.viewEndpoint + decodeUtf8(objectName)
|
||||
})
|
||||
}
|
||||
})
|
||||
|
@ -130,7 +131,15 @@ async function ossGenerateSTS() {
|
|||
}
|
||||
return
|
||||
}
|
||||
|
||||
function decodeUtf8(bytes) {
|
||||
let str = bytes.split('?');
|
||||
let str2 = str[0].split('/');
|
||||
let name = str2[str2.length - 1];
|
||||
name = encodeURIComponent(name);
|
||||
str.shift();
|
||||
str2.pop();
|
||||
return str2.join("/") + '/' + name;
|
||||
}
|
||||
|
||||
|
||||
export const OSSclient = ossGenerateSTS
|
||||
|
|
|
@ -6,7 +6,6 @@ const CopyPlugin = require('copy-webpack-plugin')
|
|||
const WebpackAliyunOss = require('webpack-aliyun-oss')
|
||||
const moment = require('moment')
|
||||
var distDate = moment(new Date()).format('YYYY-MM-DD')
|
||||
console.log(distDate)
|
||||
function resolve(dir) {
|
||||
// eslint-disable-next-line no-undef
|
||||
return path.join(__dirname, dir)
|
||||
|
@ -36,7 +35,7 @@ module.exports = {
|
|||
},
|
||||
proxy: {
|
||||
'/UploadHub': {
|
||||
// target: 'http://47.90.210.20:8000', //美国服务器
|
||||
// target: 'http://44.218.11.19:30000', //美国服务器
|
||||
// target: 'http://123.56.181.144:8001', // 国内生产环境
|
||||
// target: 'http://123.56.181.144:8060/api', // 国内测试环境1
|
||||
// target: 'http://123.56.181.144:8000/api', // 国内测试环境
|
||||
|
@ -57,15 +56,15 @@ module.exports = {
|
|||
}
|
||||
},
|
||||
'/api': {
|
||||
// target: 'http://47.90.210.20:8000', //美国服务器
|
||||
// target: 'http://44.218.11.19:30000', //美国服务器
|
||||
// target: 'http://123.56.181.144:8001', // 国内生产环境
|
||||
// target: 'http://123.56.181.144:8060/api', // 国内测试环境1
|
||||
// target: 'http://123.56.181.144:8000/api', // 国内测试环境
|
||||
// target: 'http://123.56.94.154:8079', // 国内测试环境2
|
||||
// target: 'http://123.56.94.154:7000', // 国内测试环境2
|
||||
// target: 'http://123.56.94.154:30668',
|
||||
target: 'http://106.14.89.110:30000',
|
||||
// target: 'http://123.56.181.144:7000',
|
||||
// target: 'http://106.14.89.110:30000',
|
||||
target: 'http://123.56.181.144:7000',
|
||||
changeOrigin: true,
|
||||
secure: false,
|
||||
pathRewrite: {
|
||||
|
|
Loading…
Reference in New Issue