|
|
@@ -84,23 +84,28 @@ export const uploadFile = (filePath: string, businessType: string): Promise<Uplo
|
|
|
const result = JSON.parse(resData) as UTSJSONObject
|
|
|
// 获取第一个文件信息
|
|
|
const fileInfo = result as UTSJSONObject
|
|
|
- const fileName = fileInfo['fileName'] as string
|
|
|
-
|
|
|
- // 构建完整的 URL
|
|
|
- const url = getFileViewUrl(fileName)
|
|
|
-
|
|
|
- // 返回 UploadResponse
|
|
|
- const uploadResult: UploadResponse = {
|
|
|
- url: url,
|
|
|
- fileId: fileName,
|
|
|
- fileName: fileName,
|
|
|
- filePath: filePath,
|
|
|
- fileSize: 0,
|
|
|
- fileExt: '',
|
|
|
- businessType: businessType
|
|
|
- }
|
|
|
-
|
|
|
- resolve(uploadResult)
|
|
|
+ let code = fileInfo["code"] as number | null;
|
|
|
+ let msg = fileInfo["msg"] as string | null;
|
|
|
+ if (code == 200) {
|
|
|
+ const fileName = fileInfo['fileName'] as string
|
|
|
+ // 构建完整的 URL
|
|
|
+ const url = getFileViewUrl(fileName)
|
|
|
+ // 返回 UploadResponse
|
|
|
+ const uploadResult: UploadResponse = {
|
|
|
+ url: url,
|
|
|
+ fileId: fileName,
|
|
|
+ fileName: fileName,
|
|
|
+ filePath: filePath,
|
|
|
+ fileSize: 0,
|
|
|
+ fileExt: '',
|
|
|
+ businessType: businessType
|
|
|
+ }
|
|
|
+ resolve(uploadResult)
|
|
|
+ }else{
|
|
|
+ const errorMsg = msg != null ? msg : "请求失败";
|
|
|
+ console.error('响应数据解析失败:', errorMsg)
|
|
|
+ reject(new Error(errorMsg))
|
|
|
+ }
|
|
|
} catch (e: any) {
|
|
|
console.error('响应数据解析失败:', e)
|
|
|
reject(new Error('响应数据解析失败'))
|