Skip to content

Commit 2e96da7

Browse files
author
Ajit Kumar
committed
fix(suscription image upload)
1 parent 06202bb commit 2e96da7

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

server/apis/sponsor.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,15 @@ router.post('/', async (req, res) => {
6767
token: purchaseToken,
6868
});
6969

70-
const filename = `${crypto.randomUUID()}.png`;
70+
let extension = 'png';
71+
72+
try {
73+
extension = image.split(';')?.[0].split('/')?.[1].split('+')?.[0] || 'png';
74+
} catch (_error) {
75+
extension = 'png';
76+
}
77+
78+
const filename = `${crypto.randomUUID()}.${extension}`;
7179
const path = resolve(sponsorImagesPath, filename);
7280

7381
if (!existsSync(sponsorImagesPath)) {

0 commit comments

Comments
 (0)