/*
 * @Author: donghao donghao@supervision.ltd
 * @Date: 2024-05-24 10:22:49
 * @LastEditors: donghao donghao@supervision.ltd
 * @LastEditTime: 2024-05-24 11:37:29
 * @FilePath: \general-ai-platform-web\src\hooks\useUploadFile.tsx
 * @Description: 文件上传
 */

export type useUploadFileProps = {
  getBase64: (arg1: any) => Promise;
};
export const useUploadFile: useUploadFileProps = () => {
  // 将文件转换为Base64编码
  const getBase64 = (file) => {
    return new Promise((resolve, reject) => {
      const reader = new FileReader();
      reader.readAsDataURL(file);
      reader.onload = () => resolve(reader.result);
      reader.onerror = (error) => reject(error);
    });
  };
  return {
    getBase64,
  };
};
