From a3b2942872a692237c8ea80d1751b28beeba8fb1 Mon Sep 17 00:00:00 2001 From: imeepos Date: Sun, 28 Sep 2025 15:43:00 +0800 Subject: [PATCH] fix: improve file upload handling in BowongAI SDK - Remove unused onProgress parameter in H5 upload method - Fix file name generation with proper extension formatting - Add file type detection from tempFiles for better upload accuracy - Clean up URL construction for consistent API calls --- src/sdk/bowongAISDK.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/sdk/bowongAISDK.ts b/src/sdk/bowongAISDK.ts index 3766bac..a594d9f 100644 --- a/src/sdk/bowongAISDK.ts +++ b/src/sdk/bowongAISDK.ts @@ -76,8 +76,8 @@ export class BowongAISDK { * @private */ private async _uploadFileForH5(params: UploadParams): Promise { - const { filePath, name, type, onProgress } = params; - const url = `${this._isH5Platform() ? '' : this.baseUrl}/api/file/upload/s3`; + const { filePath, name, type } = params; + const url = `${this.baseUrl}/api/file/upload/s3`; try { // 获取文件信息 @@ -94,7 +94,7 @@ export class BowongAISDK { } // 自动生成文件名(如果未提供) - const fileName = name || `upload_${Date.now()}.${this._getFileExtension(filePath)}`; + const fileName = name || `upload_${Date.now()}_${this._getFileExtension(filePath)}`; // 自动判断文件类型(如果未提供) const fileType = type || this._getMimeType(filePath); @@ -349,10 +349,12 @@ export class BowongAISDK { // 上传第一张图片 const filePath = chooseResult.tempFilePaths[0]; + const tempFile = chooseResult.tempFiles[0] console.log('开始上传图片:', filePath); const uploadUrl = await this.upload({ filePath, + type: tempFile.type, onProgress });