Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- app.get("/test2", (req, res) => {
- const dbPath = path.resolve(path.resolve(DATABASE_DIRECTORY), "test.db");
- if (!fs.existsSync(dbPath)) {
- console.error("Database file not found:", dbPath);
- return res.status(404).send("Database file not found");
- }
- console.log("Sending file:", dbPath);
- res.setHeader("Content-Type", "application/x-sqlite3");
- res.setHeader("Content-Disposition", "attachment; filename=test.db");
- const fileStream = fs.createReadStream(dbPath);
- fileStream.pipe(res);
- fileStream.on("error", (error) => {
- console.error("Error streaming file:", error);
- res.status(500).send("Error streaming database");
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement