import request from '/@/utils/request';

// OSS 上传响应
export interface OssUploadResponse {
	fileName: string;
	fileURL: string;
	fileSize: number;
	fileFormat: string;
	fileAddressPrefix: string;
	files: any;
}

/**
 * 公共文件上传到 OSS
 * @param file 文件对象
 * @param config 请求配置
 * @returns 返回文件名、文件地址、文件大小等信息
 */
export function uploadFile(file: File, config?: any) {
	const formData = new FormData();
	formData.append('file', file);

	return request<OssUploadResponse>({
		url: '/oss/file/uploadFile',
		method: 'post',
		data: formData,
		headers: {
			'Content-Type': 'multipart/form-data',
		},
		...config,
	});
}
