|
|
|
|
@ -66,10 +66,23 @@ app.post("/convert", upload.fields([{ name: "audio" }, { name: "image" }]), asyn
@@ -66,10 +66,23 @@ app.post("/convert", upload.fields([{ name: "audio" }, { name: "image" }]), asyn
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
console.log("✅ Conversion complete. Sending file..."); |
|
|
|
|
res.download(output, () => { |
|
|
|
|
res.setHeader('Content-Type', 'video/mp4'); |
|
|
|
|
res.setHeader('Content-Disposition', `attachment; filename="${output}"`); |
|
|
|
|
|
|
|
|
|
const stream = fs.createReadStream(output); |
|
|
|
|
|
|
|
|
|
stream.pipe(res); |
|
|
|
|
|
|
|
|
|
stream.on('close', () => { |
|
|
|
|
fs.unlinkSync(audioPath); |
|
|
|
|
fs.unlinkSync(imagePath); |
|
|
|
|
fs.unlinkSync(output); |
|
|
|
|
console.log("🧹 Cleaned up temp files"); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
stream.on('error', (err) => { |
|
|
|
|
console.error("❌ Stream error:", err); |
|
|
|
|
res.status(500).send("Error streaming file."); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|