mirror of
https://github.com/R0m1k3/Socialflow.git
synced 2026-10-11 17:26:45 +02:00
Improve media upload process with enhanced logging and error handling
Add console logs for receiving and processing edited image uploads, Cloudinary configuration checks, and database saving. Update error handling for Cloudinary uploads and database saving. Replit-Commit-Author: Agent Replit-Commit-Session-Id: ae4037a0-2a6f-4530-9bac-79b543286bda Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/397bca8c-984f-43ff-841a-10897aeb8140/ae4037a0-2a6f-4530-9bac-79b543286bda/VEZwUqa
This commit is contained in:
1 parent
b764cdfc48
commit
d8d691e95b
2 files changed
+12
-1
No files matched your search
Binary file not shown.
|
After Width: | Height: | Size: 16 KiB |
+12
-1
@@ -1174,10 +1174,15 @@ export async function registerRoutes(app: Express): Promise<Server> {
|
||||
// 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<Server> {
|
||||
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<Server> {
|
||||
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<Server> {
|
||||
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 });
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user