Files
chart-view/src/api/fts.ts
2026-07-03 15:50:55 +08:00

30 lines
950 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { AxiosProgressEvent } from "axios";
import axiosInstance from '@/api/axios'
import { ContentTypeEnum } from '@/enums/httpEnum'
/** 上传文件 */
const FtsUpload = (data: any, onUploadProgress?: (progress: number) => void) => {
data.append('provider', 'local')
data.append('bucket', 'visual')
// 使用完整URL绕过 /Visual/v1 前缀
const baseUrl = import.meta.env.PROD ? import.meta.env.VITE_PRO_PATH : import.meta.env.VITE_DEV_PATH
return axiosInstance({
url: `${baseUrl}/Assets/v1/fts/uploader`,
method: 'POST',
data,
headers: {
'Content-Type': ContentTypeEnum.FORM_DATA
},
onUploadProgress: onUploadProgress ? (progressEvent: AxiosProgressEvent) => {
if (progressEvent.total) {
const percentCompleted = Math.round((progressEvent.loaded * 100) / progressEvent.total);
onUploadProgress(percentCompleted);
}
} : undefined
})
}
export default FtsUpload