update validate file name only 95 char

This commit is contained in:
Adisak 2025-10-31 16:34:28 +07:00
parent a2712839d0
commit 6b7c7dcf06

View file

@ -181,11 +181,13 @@ export class DocumentController extends Controller {
let fileList = !body.replace
? body.fileList.map(({ fileName, ...props }) => {
const dotIndex = fileName.lastIndexOf(".");
const originalName =
let originalName =
dotIndex !== -1 && !fileName.startsWith(".") ? fileName.slice(0, dotIndex) : fileName;
const extension =
dotIndex !== -1 && !fileName.startsWith(".") ? fileName.slice(dotIndex) : "";
if([...originalName].length > 95){
originalName = [...originalName].slice(0, 95).join('');
}
let i = 1;
while (list.findIndex((v) => v.fileName === fileName) !== -1 || used.includes(fileName)) {
fileName = `${originalName} (${i++})`;