基础设施:增加前端直连上传文件到S3服务的功能

pull/420/head
shizhong 2024-03-11 12:59:37 +08:00
parent c26eb543e0
commit a7c37bce14
1 changed files with 4 additions and 9 deletions

View File

@ -43,8 +43,7 @@
<XModal v-model="uploadDialogVisible" :title="uploadDialogTitle">
<el-upload
ref="uploadRef"
:action="updateUrl + '?updateSupport=' + updateSupport"
:headers="uploadHeaders"
:action="uploadUrl"
:drag="true"
:limit="1"
:multiple="true"
@ -57,6 +56,7 @@
:before-remove="beforeRemove"
:on-change="handleFileChange"
:auto-upload="false"
:http-request="httpRequest"
accept=".jpg, .png, .gif"
>
<Icon icon="ep:upload-filled" />
@ -83,7 +83,7 @@ import type { UploadInstance, UploadRawFile, UploadProps, UploadFile } from 'ele
// import
import { allSchemas } from './fileList.data'
import * as FileApi from '@/api/infra/fileList'
import { getAccessToken, getTenantId } from '@/utils/auth'
import { useUpload } from '@/components/UploadFile/src/useUpload'
// import { useClipboard } from '@vueuse/core'
defineOptions({ name: 'InfraFile' })
@ -106,8 +106,7 @@ const uploadDialogTitle = ref('上传')
const updateSupport = ref(0)
const uploadDisabled = ref(false)
const uploadRef = ref<UploadInstance>()
let updateUrl = import.meta.env.VITE_UPLOAD_URL
const uploadHeaders = ref()
const { uploadUrl, httpRequest } = useUpload()
//
const beforeUpload = (file: UploadRawFile) => {
const isImg = file.type === 'image/jpeg' || 'image/gif' || 'image/png'
@ -124,10 +123,6 @@ const handleFileChange = (uploadFile: UploadFile): void => {
}
//
const submitFileForm = () => {
uploadHeaders.value = {
Authorization: 'Bearer ' + getAccessToken(),
'tenant-id': getTenantId()
}
uploadDisabled.value = true
uploadRef.value!.submit()
}