Files
cpms_operation_platform/src/api/upload.ts
T
2026-07-25 09:39:56 +08:00

28 lines
737 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 { get } from '@/utils/request';
import type { OssUploadTypeValue } from '@/utils/oss';
/** OSS 签名数据 */
export interface OssSignData {
host: string;
dir: string;
policy: string;
signature: string;
x_oss_credential: string;
x_oss_date: string;
security_token: string;
}
/**
* 获取 OSS 上传签名
* @param type 上传类型(参见 OssUploadType
*/
export async function fetchOssSign(type: OssUploadTypeValue): Promise<OssSignData> {
// 后端签名接口地址(待对接时调整)
const res: any = await get('/sys/oss/getUploadSign', { type });
const data = res?.data as OssSignData;
if (!data?.host) {
throw new Error(res?.msg || '获取上传凭证失败');
}
return data;
}