oss上传文件名称问题
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
289230b72c
commit
85a518d900
20
src/main.js
20
src/main.js
|
@ -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)
|
||||||
|
|
|
@ -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()
|
||||||
|
|
Loading…
Reference in New Issue