From bd6cef6f92503b9c6000938d941e42d7f7f5567c Mon Sep 17 00:00:00 2001 From: kartofen Date: Wed, 26 Oct 2022 22:25:23 +0300 Subject: fix image save bug --- src/lib/image.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/lib/image.ts') diff --git a/src/lib/image.ts b/src/lib/image.ts index 3f19128..69aa0b0 100644 --- a/src/lib/image.ts +++ b/src/lib/image.ts @@ -1,17 +1,17 @@ import { v4 as uuidV4 } from 'uuid'; -import { writeFileSync } from 'fs'; +import { writeFileSync, mkdir } from 'fs'; export function saveImg(img: string): string { if(!img) return null; - let filename = `/images/${uuidV4()}.${img.split(';')[0].split('/')[1]}`; + let filename = `${uuidV4()}.${img.split(';')[0].split('/')[1]}`; let path; if(process.env.DEV) { - path = `public/${filename}`; + path = `/public/${filename}`; } else { - path = `dist/client/${filename}`; + path = `/dist/client/${filename}`; } writeFileSync(path, img.split(',')[1], "base64"); -- cgit v1.2.3