fix: Supabase storage upload hatasını çözmek için dosya adlarındaki Türkçe karakterler ve boşluklar temizlendi

This commit is contained in:
mstfyldz
2026-08-12 11:22:05 +03:00
parent 571e1f63d1
commit e25bab8146
5 changed files with 47 additions and 2 deletions
+7 -1
View File
@@ -389,7 +389,13 @@ export const uploadDocument = async (req: AuthenticatedRequest, res: Response) =
}
// 2. Upload File to Supabase Storage
const filePath = `${user_id}/${Date.now()}_${file.originalname}`;
const sanitizeFilename = (name: string) => {
const charMap: Record<string, string> = { 'ç': 'c', 'ğ': 'g', 'ı': 'i', 'ö': 'o', 'ş': 's', 'ü': 'u', 'Ç': 'C', 'Ğ': 'G', 'İ': 'I', 'Ö': 'O', 'Ş': 'S', 'Ü': 'U' };
const engName = name.replace(/[çğıöşüÇĞİÖŞÜ]/g, m => charMap[m]);
return engName.replace(/[^a-zA-Z0-9.\-_]/g, '_');
};
const safeName = sanitizeFilename(file.originalname);
const filePath = `${user_id}/${Date.now()}_${safeName}`;
const { error: uploadError } = await supabase.storage
.from('case-documents')
.upload(filePath, file.buffer, {