You've already forked DataMate
fix(upload): 修复流式上传中的文件名处理逻辑
- 修正预上传接口调用时传递正确的文件总数而非固定值-1 - 移除导入配置中文件分割时的文件扩展名保留逻辑 - 删除流式上传选项中的fileExtension参数定义 - 移除流式上传实现中的文件扩展名处理相关代码 - 简化新文件名生成逻辑,不再附加扩展名后缀
This commit is contained in:
@@ -403,7 +403,6 @@ export function readFileAsText(
|
||||
export interface StreamUploadOptions {
|
||||
reqId: number;
|
||||
fileNamePrefix?: string;
|
||||
fileExtension?: string;
|
||||
hasArchive?: boolean;
|
||||
prefix?: string;
|
||||
signal?: AbortSignal;
|
||||
@@ -423,7 +422,7 @@ export async function streamSplitAndUpload(
|
||||
chunkSize: number = 1024 * 1024, // 1MB
|
||||
options: StreamUploadOptions
|
||||
): Promise<StreamUploadResult> {
|
||||
const { reqId, fileNamePrefix, fileExtension = ".txt", prefix, signal, maxConcurrency = 3 } = options;
|
||||
const { reqId, fileNamePrefix, prefix, signal, maxConcurrency = 3 } = options;
|
||||
|
||||
const fileSize = file.size;
|
||||
let offset = 0;
|
||||
@@ -434,7 +433,6 @@ export async function streamSplitAndUpload(
|
||||
|
||||
// 获取文件名基础部分
|
||||
const baseName = fileNamePrefix || file.name.replace(/\.[^/.]+$/, "");
|
||||
const ext = fileExtension.startsWith(".") ? fileExtension : `.${fileExtension}`;
|
||||
|
||||
// 用于并发控制的队列
|
||||
const uploadQueue: Promise<void>[] = [];
|
||||
@@ -449,7 +447,7 @@ export async function streamSplitAndUpload(
|
||||
return;
|
||||
}
|
||||
|
||||
const newFileName = `${baseName}_${String(index + 1).padStart(6, "0")}${ext}`;
|
||||
const newFileName = `${baseName}_${String(index + 1).padStart(6, "0")}`;
|
||||
const blob = new Blob([line], { type: "text/plain" });
|
||||
const lineFile = new File([blob], newFileName, { type: "text/plain" });
|
||||
|
||||
|
||||
Reference in New Issue
Block a user