修复:修复文件上传的权限问题
This commit is contained in:
parent
0d187aba64
commit
d5d570829b
@ -119,13 +119,21 @@ export const knowledgeBaseApi = {
|
||||
*/
|
||||
uploadFile: async (formData, dbId) => {
|
||||
checkAdminPermission()
|
||||
const userStore = useUserStore()
|
||||
const authHeaders = userStore.getAuthHeaders()
|
||||
|
||||
return fetch(`/api/data/upload?db_id=${dbId}`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
...useUserStore().getAuthHeaders()
|
||||
...authHeaders
|
||||
},
|
||||
body: formData
|
||||
}).then(res => res.json())
|
||||
}).then(res => {
|
||||
if (!res.ok) {
|
||||
throw new Error(`上传失败: ${res.status} ${res.statusText}`)
|
||||
}
|
||||
return res.json()
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
@ -127,6 +127,7 @@
|
||||
:multiple="true"
|
||||
:disabled="state.loading"
|
||||
:action="'/api/data/upload?db_id=' + databaseId"
|
||||
:headers="getAuthHeaders()"
|
||||
@change="handleFileUpload"
|
||||
@drop="handleDrop"
|
||||
>
|
||||
@ -316,6 +317,7 @@ import { onMounted, reactive, ref, watch, toRaw, onUnmounted, computed } from 'v
|
||||
import { message, Modal } from 'ant-design-vue';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
import { useConfigStore } from '@/stores/config'
|
||||
import { useUserStore } from '@/stores/user'
|
||||
import { knowledgeBaseApi } from '@/apis/admin_api'
|
||||
import HeaderComponent from '@/components/HeaderComponent.vue';
|
||||
import {
|
||||
@ -799,6 +801,11 @@ const chunkData = () => {
|
||||
}
|
||||
}
|
||||
|
||||
const getAuthHeaders = () => {
|
||||
const userStore = useUserStore();
|
||||
return userStore.getAuthHeaders();
|
||||
};
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user