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
This commit is contained in:
parent
d55730f317
commit
a3b2942872
|
|
@ -76,8 +76,8 @@ export class BowongAISDK {
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
private async _uploadFileForH5(params: UploadParams): Promise<string> {
|
private async _uploadFileForH5(params: UploadParams): Promise<string> {
|
||||||
const { filePath, name, type, onProgress } = params;
|
const { filePath, name, type } = params;
|
||||||
const url = `${this._isH5Platform() ? '' : this.baseUrl}/api/file/upload/s3`;
|
const url = `${this.baseUrl}/api/file/upload/s3`;
|
||||||
|
|
||||||
try {
|
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);
|
const fileType = type || this._getMimeType(filePath);
|
||||||
|
|
||||||
|
|
@ -349,10 +349,12 @@ export class BowongAISDK {
|
||||||
|
|
||||||
// 上传第一张图片
|
// 上传第一张图片
|
||||||
const filePath = chooseResult.tempFilePaths[0];
|
const filePath = chooseResult.tempFilePaths[0];
|
||||||
|
const tempFile = chooseResult.tempFiles[0]
|
||||||
console.log('开始上传图片:', filePath);
|
console.log('开始上传图片:', filePath);
|
||||||
|
|
||||||
const uploadUrl = await this.upload({
|
const uploadUrl = await this.upload({
|
||||||
filePath,
|
filePath,
|
||||||
|
type: tempFile.type,
|
||||||
onProgress
|
onProgress
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue