Skip to content

Commit 2b1b12f

Browse files
committed
[FIX] demo: missing waiting on image upload
The route `upload-image` in the demo server wasn't waiting for the stream to write the whole image to a file before sending the response. This led to corrupted images when trying to create a figure with a large image. closes #6116 Task: 0 Signed-off-by: Rémi Rahir (rar) <rar@odoo.com>
1 parent 6ac8bb7 commit 2b1b12f

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

tools/server/main.cjs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,10 @@ app.post("/upload-image", function (req, res) {
112112
// This opens up the writeable stream to `output`
113113
const writeStream = fs.createWriteStream(output);
114114
// This pipes the POST data to the file
115+
writeStream.on("finish", () => {
116+
res.send("../" + output);
117+
});
115118
readStream.pipe(writeStream);
116-
res.send("../" + output);
117119
}
118120
});
119121
} catch (err) {

0 commit comments

Comments
 (0)