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.download = download
|
||||||
Vue.prototype.handleTree = handleTree
|
Vue.prototype.handleTree = handleTree
|
||||||
Vue.prototype.$getObjectName = (url) => {
|
Vue.prototype.$getObjectName = (url) => {
|
||||||
// console.log(Vue.prototype.)
|
// console.log(url,'url')
|
||||||
// console.log(url)
|
// console.log(Vue.prototype.OSSclientConfig.viewEndpoint,'url')
|
||||||
var value = 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)
|
|
||||||
let basePath = Vue.prototype.OSSclientConfig.viewEndpoint;
|
let basePath = Vue.prototype.OSSclientConfig.viewEndpoint;
|
||||||
let basePathHttp = Vue.prototype.OSSclientConfig.viewEndpoint.replace("https", 'http')
|
if (Vue.prototype.OSSclientConfig.ObjectStoreUse === 'AliyunOSS') {
|
||||||
let arr = value.split(basePath);
|
basePath = Vue.prototype.OSSclientConfig.endPoint.split('https://').length > 1 ? Vue.prototype.OSSclientConfig.endPoint.split('https://')[1] : Vue.prototype.OSSclientConfig.endPoint;
|
||||||
let name = null;
|
|
||||||
if (arr.length > 1) {
|
|
||||||
name = arr[1];
|
|
||||||
} else {
|
|
||||||
name = value.split(basePathHttp)[1];
|
|
||||||
}
|
}
|
||||||
// console.log(name)
|
return value.split(basePath)[1];
|
||||||
return name;
|
|
||||||
}
|
}
|
||||||
Vue.prototype.getGuid = (text) => {
|
Vue.prototype.getGuid = (text) => {
|
||||||
text = md5(text)
|
text = md5(text)
|
||||||
|
|
|
@ -20,8 +20,8 @@ function blobToBuffer(blob, fileName) {
|
||||||
async function ossGenerateSTS() {
|
async function ossGenerateSTS() {
|
||||||
let res = await GetObjectStoreToken()
|
let res = await GetObjectStoreToken()
|
||||||
Vue.prototype.OSSclientConfig = { ...res.Result[res.Result.ObjectStoreUse] }
|
Vue.prototype.OSSclientConfig = { ...res.Result[res.Result.ObjectStoreUse] }
|
||||||
|
Vue.prototype.OSSclientConfig.ObjectStoreUse = res.Result.ObjectStoreUse;
|
||||||
Vue.prototype.OSSclientConfig.basePath = Vue.prototype.OSSclientConfig.viewEndpoint
|
Vue.prototype.OSSclientConfig.basePath = Vue.prototype.OSSclientConfig.viewEndpoint
|
||||||
console.log(Vue.prototype.OSSclientConfig.basePath)
|
|
||||||
switch (res.Result.ObjectStoreUse) {
|
switch (res.Result.ObjectStoreUse) {
|
||||||
case 'AliyunOSS':
|
case 'AliyunOSS':
|
||||||
Vue.prototype.OSSclientConfig.bucket = Vue.prototype.OSSclientConfig.bucketName
|
Vue.prototype.OSSclientConfig.bucket = Vue.prototype.OSSclientConfig.bucketName
|
||||||
|
@ -78,7 +78,7 @@ async function ossGenerateSTS() {
|
||||||
} else {
|
} else {
|
||||||
resolve({
|
resolve({
|
||||||
name: objectName,
|
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)
|
console.log(err)
|
||||||
reject()
|
reject()
|
||||||
} else {
|
} else {
|
||||||
|
console.log(objectName);
|
||||||
resolve({
|
resolve({
|
||||||
name: objectName,
|
name: objectName,
|
||||||
url: 'http://www.abc.com' + objectName
|
url: Vue.prototype.OSSclientConfig.viewEndpoint + decodeUtf8(objectName)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -130,7 +131,15 @@ async function ossGenerateSTS() {
|
||||||
}
|
}
|
||||||
return
|
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
|
export const OSSclient = ossGenerateSTS
|
||||||
|
|
|
@ -6,7 +6,6 @@ const CopyPlugin = require('copy-webpack-plugin')
|
||||||
const WebpackAliyunOss = require('webpack-aliyun-oss')
|
const WebpackAliyunOss = require('webpack-aliyun-oss')
|
||||||
const moment = require('moment')
|
const moment = require('moment')
|
||||||
var distDate = moment(new Date()).format('YYYY-MM-DD')
|
var distDate = moment(new Date()).format('YYYY-MM-DD')
|
||||||
console.log(distDate)
|
|
||||||
function resolve(dir) {
|
function resolve(dir) {
|
||||||
// eslint-disable-next-line no-undef
|
// eslint-disable-next-line no-undef
|
||||||
return path.join(__dirname, dir)
|
return path.join(__dirname, dir)
|
||||||
|
@ -36,7 +35,7 @@ module.exports = {
|
||||||
},
|
},
|
||||||
proxy: {
|
proxy: {
|
||||||
'/UploadHub': {
|
'/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:8001', // 国内生产环境
|
||||||
// target: 'http://123.56.181.144:8060/api', // 国内测试环境1
|
// target: 'http://123.56.181.144:8060/api', // 国内测试环境1
|
||||||
// target: 'http://123.56.181.144:8000/api', // 国内测试环境
|
// target: 'http://123.56.181.144:8000/api', // 国内测试环境
|
||||||
|
@ -57,15 +56,15 @@ module.exports = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'/api': {
|
'/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:8001', // 国内生产环境
|
||||||
// target: 'http://123.56.181.144:8060/api', // 国内测试环境1
|
// target: 'http://123.56.181.144:8060/api', // 国内测试环境1
|
||||||
// target: 'http://123.56.181.144:8000/api', // 国内测试环境
|
// target: 'http://123.56.181.144:8000/api', // 国内测试环境
|
||||||
// target: 'http://123.56.94.154:8079', // 国内测试环境2
|
// target: 'http://123.56.94.154:8079', // 国内测试环境2
|
||||||
// target: 'http://123.56.94.154:7000', // 国内测试环境2
|
// target: 'http://123.56.94.154:7000', // 国内测试环境2
|
||||||
// target: 'http://123.56.94.154:30668',
|
// target: 'http://123.56.94.154:30668',
|
||||||
target: 'http://106.14.89.110:30000',
|
// target: 'http://106.14.89.110:30000',
|
||||||
// target: 'http://123.56.181.144:7000',
|
target: 'http://123.56.181.144:7000',
|
||||||
changeOrigin: true,
|
changeOrigin: true,
|
||||||
secure: false,
|
secure: false,
|
||||||
pathRewrite: {
|
pathRewrite: {
|
||||||
|
|
Loading…
Reference in New Issue