oss上传文件名称问题
continuous-integration/drone/push Build is passing Details

uat_us
wangxiaoshuang 2024-05-15 10:16:04 +08:00
parent 289230b72c
commit 85a518d900
2 changed files with 60 additions and 47 deletions

View File

@ -96,12 +96,24 @@ 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) // console.log(url)
var value = url var value = url
var str = value.split("//"); //https://进行分割, // var str = value.split("//"); //https://进行分割,
var index = str[1].indexOf("/")+1; //indexOf 获取第一个斜杠的索引, // var index = str[1].indexOf("/")+1; //indexOf 获取第一个斜杠的索引,
// console.log(str[1].substring(index)); //substring 截取, // // console.log(str[1].substring(index)); //substring 截取,
return '/' + str[1].substring(index) // return '/' + str[1].substring(index)
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];
}
// console.log(name)
return name;
} }
Vue.prototype.getGuid = (text) => { Vue.prototype.getGuid = (text) => {
text = md5(text) text = md5(text)

View File

@ -21,6 +21,7 @@ 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.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
@ -40,7 +41,7 @@ async function ossGenerateSTS() {
if (res && res.url) { if (res && res.url) {
resolve({ resolve({
name: objectName, name: objectName,
url: Vue.prototype.OSSclientConfig.viewEndpoint + objectName url: res.url
}) })
} else { } else {
reject() reject()