Skip to content

Commit

Permalink
fix(sys-client): fix files api;
Browse files Browse the repository at this point in the history
  • Loading branch information
maslow committed Sep 3, 2021
1 parent ef31305 commit 7ed35d9
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions packages/system-client/src/api/file.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

import store from '@/store'
import { assert } from '@/utils/assert'
import request from '@/utils/request'

Expand All @@ -7,8 +8,9 @@ import request from '@/utils/request'
* @returns
*/
export async function getFileBuckets() {
const appid = store.state.app.appid
const res = await request({
url: `/file/buckets`,
url: `/apps/${appid}/file/buckets`,
method: 'get'
})

Expand All @@ -22,8 +24,9 @@ export async function getFileBuckets() {
* @returns {Promise<any[]>}
*/
export async function createFileBucket(bucketName) {
const appid = store.state.app.appid
const res = await request({
url: `/file/buckets`,
url: `/apps/${appid}/file/buckets`,
method: 'post',
data: {
bucket: bucketName
Expand All @@ -39,8 +42,9 @@ export async function createFileBucket(bucketName) {
* @returns
*/
export async function deleteFileBucket(bucketName) {
const appid = store.state.app.appid
const res = await request({
url: `/file/buckets/${bucketName}`,
url: `/apps/${appid}/file/buckets/${bucketName}`,
method: 'delete'
})

Expand All @@ -61,8 +65,9 @@ export async function getFilesByBucketName(bucketName, { offset, limit, keyword
query = query + `&keyword=${keyword}`
}

const appid = store.state.app.appid
const res = await request({
url: `/file/${bucketName}/files?${query}`,
url: `/apps/${appid}/file/${bucketName}/files?${query}`,
method: 'GET'
})
assert(res.code === 0, `get files in ${bucketName} got error`, res)
Expand All @@ -79,8 +84,9 @@ export async function deleteFileById(bucketName, file_id) {
assert(bucketName, 'empty bucketName got')
assert(file_id, 'empty file_id got')

const appid = store.state.app.appid
const res = await request({
url: `/file/${bucketName}/${file_id}`,
url: `/apps/${appid}/file/${bucketName}/${file_id}`,
method: 'DELETE'
})

Expand Down

0 comments on commit 7ed35d9

Please sign in to comment.