Skip to content

Commit 2c6370f

Browse files
Update components/alttextify/actions/submit-image/submit-image.mjs
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
1 parent a2f4c83 commit 2c6370f

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

components/alttextify/actions/submit-image/submit-image.mjs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,15 @@ export default {
8181
methods: {
8282
async streamToBase64(stream) {
8383
return new Promise((resolve, reject) => {
84-
let base64String = "";
84+
const chunks = [];
8585

8686
stream.on("data", (chunk) => {
87-
base64String += Buffer.from(chunk).toString("base64");
87+
chunks.push(chunk);
8888
});
8989

9090
stream.on("end", () => {
91-
resolve(base64String);
91+
const buffer = Buffer.concat(chunks);
92+
resolve(buffer.toString("base64"));
9293
});
9394

9495
stream.on("error", (err) => {

0 commit comments

Comments
 (0)