export class Upload { abortUpload(uploadId) { return false; } abortAllUploads() { } getUploadStatus(uploadId) { return 'not-found'; } getActiveUploads() { return []; } async uploadFile(options) { const { file, name, uploadUrl, formData, method = "POST" } = options; const isPut = method === "PUT"; if (isPut) { // S3 预签名上传 const headers = {}; if (file instanceof File) { headers["Content-Type"] = file.type || "application/octet-stream"; } const result = await fetch(uploadUrl, { method: "PUT", headers, body: file, }); return result; } else { // 表单上传 const formData2 = new FormData(); for (const key of Object.keys(formData)) { formData2.append(key, formData[key]); } formData2.append(name || "file", file); const result = await fetch(uploadUrl, { method, body: formData2, }); return result; } } }