fix: normalize image filename extension before Appwrite upload

This commit is contained in:
egecankomur
2026-05-12 05:14:37 +03:00
parent 8dd970d2ad
commit 04e11c3fed
+11 -1
View File
@@ -39,7 +39,17 @@ export async function POST(request: NextRequest) {
try {
const buffer = Buffer.from(await file.arrayBuffer());
const inputFile = InputFile.fromBuffer(buffer, file.name);
const extMap: Record<string, string> = {
"image/jpeg": ".jpg",
"image/png": ".png",
"image/webp": ".webp",
"image/gif": ".gif",
"image/avif": ".avif",
};
const ext = extMap[file.type] ?? ".jpg";
const baseName = file.name.replace(/\.[^/.]+$/, "");
const safeName = baseName + ext;
const inputFile = InputFile.fromBuffer(buffer, safeName);
const created = await storage.createFile(
BUCKETS.propertyImages,