diff --git a/attached_assets/image_1760173933493.png b/attached_assets/image_1760173933493.png new file mode 100644 index 0000000..1de1bdb Binary files /dev/null and b/attached_assets/image_1760173933493.png differ diff --git a/server/routes.ts b/server/routes.ts index 1111cc3..a4e7875 100644 --- a/server/routes.ts +++ b/server/routes.ts @@ -1174,10 +1174,15 @@ export async function registerRoutes(app: Express): Promise { // Upload edited image with overlays app.post("/api/media/upload-edited", requireAuth, upload.single("file"), async (req, res) => { try { + console.log("📸 Receiving edited image upload..."); + if (!req.file) { + console.log("❌ No file in request"); return res.status(400).json({ error: "No file uploaded" }); } + console.log("📁 File received:", req.file.originalname, req.file.size, "bytes"); + const user = req.user as User; const userId = user.id; @@ -1185,11 +1190,13 @@ export async function registerRoutes(app: Express): Promise { const cloudinaryConfig = await storage.getCloudinaryConfig(userId); if (!cloudinaryConfig) { + console.log("❌ Cloudinary not configured for user:", userId); return res.status(400).json({ error: "Cloudinary not configured. Please configure Cloudinary in Settings first." }); } + console.log("☁️ Uploading to Cloudinary..."); // Upload edited image to Cloudinary const uploadResult = await cloudinaryService.uploadMedia( req.file.buffer, @@ -1198,6 +1205,9 @@ export async function registerRoutes(app: Express): Promise { req.file.mimetype ); + console.log("✅ Cloudinary upload success:", uploadResult.publicId); + console.log("💾 Saving to database..."); + const mediaItem = await storage.createMedia({ userId, type: "image", @@ -1210,9 +1220,10 @@ export async function registerRoutes(app: Express): Promise { fileSize: req.file.size, }); + console.log("✅ Media saved to DB with ID:", mediaItem.id); res.json(mediaItem); } catch (error) { - console.error("Error uploading edited image:", error); + console.error("💥 Error uploading edited image:", error); const errorMessage = error instanceof Error ? error.message : "Failed to upload edited image"; res.status(500).json({ error: errorMessage }); }