feat: add secure remote channel media
This commit is contained in:
@@ -39,6 +39,7 @@ import type {
|
||||
SearchResult
|
||||
} from './types'
|
||||
import { UrlImporter } from './url-importer'
|
||||
import { mimeTypeFromFileName } from '../file-media-type'
|
||||
|
||||
type ScannedFile = {
|
||||
absolutePath: string
|
||||
@@ -94,27 +95,6 @@ function isInside(root: string, candidate: string): boolean {
|
||||
return path === '' || (!path.startsWith('..') && !isAbsolute(path))
|
||||
}
|
||||
|
||||
function mimeTypeFor(path: string): string {
|
||||
const extension = extname(path).toLowerCase()
|
||||
const types: Record<string, string> = {
|
||||
'.csv': 'text/csv',
|
||||
'.docx':
|
||||
'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
||||
'.html': 'text/html',
|
||||
'.htm': 'text/html',
|
||||
'.json': 'application/json',
|
||||
'.md': 'text/markdown',
|
||||
'.pdf': 'application/pdf',
|
||||
'.pptx':
|
||||
'application/vnd.openxmlformats-officedocument.presentationml.presentation',
|
||||
'.txt': 'text/plain',
|
||||
'.xlsx':
|
||||
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
||||
'.xml': 'application/xml'
|
||||
}
|
||||
return types[extension] ?? 'text/plain'
|
||||
}
|
||||
|
||||
export class KnowledgeService {
|
||||
readonly database: KnowledgeDatabase
|
||||
private readonly managedRoot: string
|
||||
@@ -633,7 +613,10 @@ export class KnowledgeService {
|
||||
sourceId: source.id,
|
||||
externalId: file.relativePath,
|
||||
title: parsed.title,
|
||||
mimeType: mimeTypeFor(file.absolutePath),
|
||||
mimeType: mimeTypeFromFileName(
|
||||
file.absolutePath,
|
||||
'text/plain'
|
||||
),
|
||||
sourceLocation: file.absolutePath,
|
||||
checksum,
|
||||
metadata: {
|
||||
|
||||
Reference in New Issue
Block a user