Parcourir la source

🐛 fix(minio): 修复小程序环境下文件名称获取错误

- 修复小程序环境下无法正确获取原始文件名的问题
- 将 fileName 获取方式从 res.tempFiles[0]?.name 修改为 res.tempFiles[0]?.originalFileObj?.name,以适配最新的 Taro 环境文件结构
yourname il y a 4 mois
Parent
commit
27b727c880
1 fichiers modifiés avec 1 ajouts et 5 suppressions
  1. 1 5
      mini/src/utils/minio.ts

+ 1 - 5
mini/src/utils/minio.ts

@@ -781,17 +781,13 @@ export async function uploadFromSelect(
 
   if (isMiniProgram) {
     return new Promise((resolve, reject) => {
-      if (typeof Taro === 'undefined') {
-        reject(new Error('Taro 环境未找到'));
-        return;
-      }
       
       Taro.chooseImage({
         count,
         sourceType: sourceType as any, // 确保类型兼容
         success: async (res) => {
           const tempFilePath = res.tempFilePaths[0];
-          const fileName = res.tempFiles[0]?.name || tempFilePath.split('/').pop() || 'unnamed-file';
+          const fileName = res.tempFiles[0]?.originalFileObj?.name || tempFilePath.split('/').pop() || 'unnamed-file';
           
           try {
             const result = await uploadMinIOWithPolicy(uploadPath, tempFilePath, fileName, callbacks);