Files
cpms_operation_platform/src/api/upload.ts
T

28 lines
737 B
TypeScript
Raw Normal View History

2026-07-25 09:39:56 +08:00
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;
}