diff --git a/apps/server/src/services/import/single.ts b/apps/server/src/services/import/single.ts index 7200d17d57..28ac4e9feb 100644 --- a/apps/server/src/services/import/single.ts +++ b/apps/server/src/services/import/single.ts @@ -57,7 +57,7 @@ function importFile(taskContext: TaskContext<"importNotes">, file: File, parentN const mime = mimeService.getMime(originalName) || file.mimetype; const { note } = noteService.createNewNote({ parentNoteId: parentNote.noteId, - title: getNoteTitle(originalName, mime === "application/pdf"), + title: getNoteTitle(originalName, mime === "application/pdf", { mime }), content: file.buffer, isProtected: parentNote.isProtected && protectedSessionService.isProtectedSessionAvailable(), type: "file", diff --git a/apps/server/src/services/utils.ts b/apps/server/src/services/utils.ts index a2b707edf9..10d4db0526 100644 --- a/apps/server/src/services/utils.ts +++ b/apps/server/src/services/utils.ts @@ -204,9 +204,13 @@ export function formatDownloadTitle(fileName: string, type: string | null, mime: return `${fileNameBase}${getExtension()}`; } -export function removeFileExtension(filePath: string) { +export function removeFileExtension(filePath: string, mime?: string) { const extension = path.extname(filePath).toLowerCase(); + if (mime?.startsWith("video/")) { + return filePath.substring(0, filePath.length - extension.length); + } + switch (extension) { case ".md": case ".mdx": @@ -227,7 +231,7 @@ export function getNoteTitle(filePath: string, replaceUnderscoresWithSpaces: boo const trimmedNoteMeta = noteMeta?.title?.trim(); if (trimmedNoteMeta) return trimmedNoteMeta; - const basename = path.basename(removeFileExtension(filePath)); + const basename = path.basename(removeFileExtension(filePath, noteMeta?.mime)); return replaceUnderscoresWithSpaces ? basename.replace(/_/g, " ").trim() : basename; }