import { http } from '@/utils/http/axios';

// 上传文件的文件夹
export enum UPLOAD_BIZ_TYPE {
  ATTACHMENT = 'ATTACHMENT',
  // 字典
  DICTIONARY = 'DICTIONARY',
}
/**
 * 上传文件到MINIO
 */

export const uploadFileApi = (data: { bizType: UPLOAD_BIZ_TYPE; fileName: string; file: File }) => {
  const formData = new FormData();
  const { bizType, fileName, file } = data;
  formData.append('bizType', bizType);
  formData.append('fileName', fileName.split('.')[0]);
  formData.append('file', file);
  return http.request<{ url: string }>({
    url: '/admin/minio/uploadFile',
    method: 'post',
    data: formData,
  });
};
