Skip to content

Commit 4809372

Browse files
committedFeb 2, 2023
remove mime type before buffering data
1 parent dbe48e7 commit 4809372

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed
 

‎functions/api-base64.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,13 @@ export const apiBase64 = onRequest({cors:true},
3838

3939
let buffer;
4040
try {
41-
buffer = Buffer.from(data, "base64");
41+
// this safely removes the mime type from the base64 data
42+
const split_data = data.split(",");
43+
if(split_data.length > 1){
44+
buffer = Buffer.from(split_data[1], "base64");
45+
} else {
46+
buffer = Buffer.from(data, "base64");
47+
}
4248
} catch (e) {
4349
res.status(400).json(MESSAGES.INVALID_BASE64_DATA);
4450
return;

0 commit comments

Comments
 (0)
Please sign in to comment.