diff --git a/es/utils/upload.d.ts b/es/utils/upload.d.ts index 3b0fd54b..754cb82e 100644 --- a/es/utils/upload.d.ts +++ b/es/utils/upload.d.ts @@ -1,5 +1,6 @@ export declare class Upload { - uploadFile(file: string | File, name: string, uploadUrl: string, formData: Record, autoInform?: boolean): Promise; + uploadFile(file: File | string, name: string, uploadUrl: string, formData: Record, autoInform?: boolean, getPercent?: Function, uploadId?: string, // 新增:上传任务ID,用于中断特定上传 + method?: "POST" | "PUT" | "PATCH"): Promise; private controllers; constructor(); abortUpload(uploadId: string): boolean; diff --git a/es/utils/upload.js b/es/utils/upload.js index 91cd0de0..e0ae7c45 100644 --- a/es/utils/upload.js +++ b/es/utils/upload.js @@ -1,5 +1,6 @@ export class Upload { - async uploadFile(file, name, uploadUrl, formData, autoInform) { + async uploadFile(file, name, uploadUrl, formData, autoInform, getPercent, uploadId, // 新增:上传任务ID,用于中断特定上传 + method = "POST") { console.warn('server不会调用此函数'); } controllers = new Map(); diff --git a/es/utils/upload.mp.d.ts b/es/utils/upload.mp.d.ts index 71c38f18..9ba84b92 100644 --- a/es/utils/upload.mp.d.ts +++ b/es/utils/upload.mp.d.ts @@ -1,3 +1,4 @@ export declare class Upload { - uploadFile(file: string | File, name: string, uploadUrl: string, formData: Record, autoInform?: boolean, getPercent?: Function, method?: "POST" | "PUT" | "PATCH"): Promise; + uploadFile(file: File | string, name: string, uploadUrl: string, formData: Record, autoInform?: boolean, getPercent?: Function, uploadId?: string, // 新增:上传任务ID,用于中断特定上传 + method?: "POST" | "PUT" | "PATCH"): Promise; } diff --git a/es/utils/upload.mp.js b/es/utils/upload.mp.js index 6b8241d0..f9fc118e 100644 --- a/es/utils/upload.mp.js +++ b/es/utils/upload.mp.js @@ -1,6 +1,7 @@ import { promisify } from './promisify'; export class Upload { - async uploadFile(file, name, uploadUrl, formData, autoInform, getPercent, method = "POST") { + async uploadFile(file, name, uploadUrl, formData, autoInform, getPercent, uploadId, // 新增:上传任务ID,用于中断特定上传 + method = "POST") { const isPut = method === "PUT"; if (isPut) { return new Promise((resolve, reject) => { diff --git a/es/utils/upload.native.d.ts b/es/utils/upload.native.d.ts index 7cadbbd5..9ba84b92 100644 --- a/es/utils/upload.native.d.ts +++ b/es/utils/upload.native.d.ts @@ -1,3 +1,4 @@ export declare class Upload { - uploadFile(file: File | string, name: string, uploadUrl: string, formData: Record, autoInform?: boolean, getPercent?: Function, method?: "POST" | "PUT" | "PATCH"): Promise; + uploadFile(file: File | string, name: string, uploadUrl: string, formData: Record, autoInform?: boolean, getPercent?: Function, uploadId?: string, // 新增:上传任务ID,用于中断特定上传 + method?: "POST" | "PUT" | "PATCH"): Promise; } diff --git a/es/utils/upload.native.js b/es/utils/upload.native.js index 3c2f8aa0..d06aa5b4 100644 --- a/es/utils/upload.native.js +++ b/es/utils/upload.native.js @@ -1,5 +1,6 @@ export class Upload { - async uploadFile(file, name, uploadUrl, formData, autoInform, getPercent, method = "POST") { + async uploadFile(file, name, uploadUrl, formData, autoInform, getPercent, uploadId, // 新增:上传任务ID,用于中断特定上传 + method = "POST") { const isPut = method === "PUT"; if (isPut) { // S3 预签名上传 diff --git a/lib/utils/upload.d.ts b/lib/utils/upload.d.ts index 3b0fd54b..754cb82e 100644 --- a/lib/utils/upload.d.ts +++ b/lib/utils/upload.d.ts @@ -1,5 +1,6 @@ export declare class Upload { - uploadFile(file: string | File, name: string, uploadUrl: string, formData: Record, autoInform?: boolean): Promise; + uploadFile(file: File | string, name: string, uploadUrl: string, formData: Record, autoInform?: boolean, getPercent?: Function, uploadId?: string, // 新增:上传任务ID,用于中断特定上传 + method?: "POST" | "PUT" | "PATCH"): Promise; private controllers; constructor(); abortUpload(uploadId: string): boolean; diff --git a/lib/utils/upload.js b/lib/utils/upload.js index d34baa96..7f74394d 100644 --- a/lib/utils/upload.js +++ b/lib/utils/upload.js @@ -2,7 +2,8 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.Upload = void 0; class Upload { - async uploadFile(file, name, uploadUrl, formData, autoInform) { + async uploadFile(file, name, uploadUrl, formData, autoInform, getPercent, uploadId, // 新增:上传任务ID,用于中断特定上传 + method = "POST") { console.warn('server不会调用此函数'); } controllers = new Map(); diff --git a/lib/utils/upload.mp.d.ts b/lib/utils/upload.mp.d.ts index 71c38f18..9ba84b92 100644 --- a/lib/utils/upload.mp.d.ts +++ b/lib/utils/upload.mp.d.ts @@ -1,3 +1,4 @@ export declare class Upload { - uploadFile(file: string | File, name: string, uploadUrl: string, formData: Record, autoInform?: boolean, getPercent?: Function, method?: "POST" | "PUT" | "PATCH"): Promise; + uploadFile(file: File | string, name: string, uploadUrl: string, formData: Record, autoInform?: boolean, getPercent?: Function, uploadId?: string, // 新增:上传任务ID,用于中断特定上传 + method?: "POST" | "PUT" | "PATCH"): Promise; } diff --git a/lib/utils/upload.mp.js b/lib/utils/upload.mp.js index 47041eb0..9f0ec806 100644 --- a/lib/utils/upload.mp.js +++ b/lib/utils/upload.mp.js @@ -3,7 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.Upload = void 0; const promisify_1 = require("./promisify"); class Upload { - async uploadFile(file, name, uploadUrl, formData, autoInform, getPercent, method = "POST") { + async uploadFile(file, name, uploadUrl, formData, autoInform, getPercent, uploadId, // 新增:上传任务ID,用于中断特定上传 + method = "POST") { const isPut = method === "PUT"; if (isPut) { return new Promise((resolve, reject) => { diff --git a/lib/utils/upload.native.d.ts b/lib/utils/upload.native.d.ts index 7cadbbd5..9ba84b92 100644 --- a/lib/utils/upload.native.d.ts +++ b/lib/utils/upload.native.d.ts @@ -1,3 +1,4 @@ export declare class Upload { - uploadFile(file: File | string, name: string, uploadUrl: string, formData: Record, autoInform?: boolean, getPercent?: Function, method?: "POST" | "PUT" | "PATCH"): Promise; + uploadFile(file: File | string, name: string, uploadUrl: string, formData: Record, autoInform?: boolean, getPercent?: Function, uploadId?: string, // 新增:上传任务ID,用于中断特定上传 + method?: "POST" | "PUT" | "PATCH"): Promise; } diff --git a/lib/utils/upload.native.js b/lib/utils/upload.native.js index c7763fae..33219587 100644 --- a/lib/utils/upload.native.js +++ b/lib/utils/upload.native.js @@ -2,7 +2,8 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.Upload = void 0; class Upload { - async uploadFile(file, name, uploadUrl, formData, autoInform, getPercent, method = "POST") { + async uploadFile(file, name, uploadUrl, formData, autoInform, getPercent, uploadId, // 新增:上传任务ID,用于中断特定上传 + method = "POST") { const isPut = method === "PUT"; if (isPut) { // S3 预签名上传 diff --git a/src/utils/upload.mp.ts b/src/utils/upload.mp.ts index ca92b506..9aa756cd 100644 --- a/src/utils/upload.mp.ts +++ b/src/utils/upload.mp.ts @@ -2,13 +2,14 @@ import { promisify } from './promisify'; export class Upload { async uploadFile( - file: string | File, + file: File | string, name: string, uploadUrl: string, formData: Record, autoInform?: boolean, getPercent?: Function, - method: "POST" | "PUT" | "PATCH" = "POST" + uploadId?: string, // 新增:上传任务ID,用于中断特定上传 + method: "POST" | "PUT" | "PATCH" = "POST", ): Promise { const isPut = method === "PUT"; diff --git a/src/utils/upload.native.ts b/src/utils/upload.native.ts index 9a0ec9c9..184875b2 100644 --- a/src/utils/upload.native.ts +++ b/src/utils/upload.native.ts @@ -8,7 +8,8 @@ export class Upload { formData: Record, autoInform?: boolean, getPercent?: Function, - method: "POST" | "PUT" | "PATCH" = "POST" + uploadId?: string, // 新增:上传任务ID,用于中断特定上传 + method: "POST" | "PUT" | "PATCH" = "POST", ): Promise { const isPut = method === "PUT"; diff --git a/src/utils/upload.ts b/src/utils/upload.ts index 9b98d991..b1e02d51 100644 --- a/src/utils/upload.ts +++ b/src/utils/upload.ts @@ -1,11 +1,14 @@ export class Upload { async uploadFile( - file: string | File, + file: File | string, name: string, uploadUrl: string, formData: Record, - autoInform?: boolean + autoInform?: boolean, + getPercent?: Function, + uploadId?: string, // 新增:上传任务ID,用于中断特定上传 + method: "POST" | "PUT" | "PATCH" = "POST", ): Promise { console.warn('server不会调用此函数') }