Skip to content

Commit

Permalink
feat(oss): impl oss external bucket url;
Browse files Browse the repository at this point in the history
  • Loading branch information
walle233 committed Apr 16, 2022
1 parent 3286322 commit 4a43aa5
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 8 deletions.
7 changes: 3 additions & 4 deletions packages/app-console/src/api/oss.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,13 @@ export async function deleteBucket(bucketName) {
}

/**
* 获取当前应用的指定文件桶的服务地址
* get bucket's url
* @param {*} bucket
* @returns
*/
export function getBucketUrl(bucket) {
const appid = store.state.app.appid
const domain = store.state.app.storage_deploy_host
const schema = store.state.app.storage_deploy_url_schema || 'http'
const url = `${schema}://${appid}-${bucket}.${domain}`
const endpoint = store.state.app.oss_external_endpoint
const url = `${endpoint}/${appid}-${bucket}`
return url
}
8 changes: 7 additions & 1 deletion packages/app-console/src/store/modules/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ const state = {
app_deploy_host: null,
app_deploy_url_schema: 'http',
storage_deploy_host: null,
storage_deploy_url_schema: 'http'
storage_deploy_url_schema: 'http',
oss_internal_endpoint: null,
oss_external_endpoint: null,
}

const mutations = {
Expand Down Expand Up @@ -60,6 +62,9 @@ const mutations = {
SET_STORAGE_DEPLOY_HOST: (state, domain) => {
state.storage_deploy_host = domain
},
SET_OSS_EXTERNAL_ENDPOINT: (state, endpoint) => {
state.oss_external_endpoint = endpoint
},
SET_STORAGE_DEPLOY_URL_SCHEMA: (state, schema) => {
state.storage_deploy_url_schema = schema
},
Expand Down Expand Up @@ -92,6 +97,7 @@ const actions = {
commit('SET_APP_DEPLOY_HOST', res.data?.app_deploy_host)
commit('SET_APP_DEPLOY_URL_SCHEMA', res.data?.app_deploy_url_schema)
commit('SET_STORAGE_DEPLOY_HOST', res.data?.storage_deploy_host)
commit('SET_OSS_EXTERNAL_ENDPOINT', res.data?.oss_external_endpoint)
commit('SET_STORAGE_DEPLOY_URL_SCHEMA', res.data?.storage_deploy_url_schema)
},
clearStates({ commit }) {
Expand Down
4 changes: 2 additions & 2 deletions packages/app-console/src/views/storage/buckets.vue
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,9 @@ export default {
this.$refs['dataForm'].validate(async(valid) => {
if (!valid) { return }
const isNameValid = /^[A-Za-z0-9\-]{1,16}$/g.test(this.form.name)
const isNameValid = /^[A-Za-z0-9]{1,16}$/g.test(this.form.name)
if (!isNameValid) {
return showError('Bucket 名称长度必须在 1~16 之间,且只能包含字母、数字和中划线')
return showError('Bucket 名称长度必须在 1~16 之间,且只能包含字母、数字')
}
// 执行创建请求
Expand Down
6 changes: 5 additions & 1 deletion packages/system-server/src/router/application/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ export async function handleGetApplicationByAppid(req: Request, res: Response) {
const app_deploy_url_schema = Config.APP_SERVICE_DEPLOY_URL_SCHEMA
const storage_deploy_host = Config.STORAGE_SERVICE_CONFIG.deploy_host
const storage_deploy_url_schema = Config.STORAGE_SERVICE_CONFIG.schema
const oss_external_endpoint = Config.MINIO_CONFIG.endpoint.external
const oss_internal_endpoint = Config.MINIO_CONFIG.endpoint.internal

app.config = undefined
return res.send({
Expand All @@ -90,7 +92,9 @@ export async function handleGetApplicationByAppid(req: Request, res: Response) {
app_deploy_host,
app_deploy_url_schema,
storage_deploy_host,
storage_deploy_url_schema
storage_deploy_url_schema,
oss_external_endpoint,
oss_internal_endpoint
}
})
}

0 comments on commit 4a43aa5

Please sign in to comment.