From e0e03e53e94e6329018525486ea8c8f3a8cfb409 Mon Sep 17 00:00:00 2001 From: euanmillar Date: Tue, 19 Nov 2024 22:08:18 +0000 Subject: [PATCH] Fix conflict in yarn lock --- .../src/features/uploadDocument/handler.ts | 37 +++++++++++++++---- yarn.lock | 6 +-- 2 files changed, 32 insertions(+), 11 deletions(-) diff --git a/packages/documents/src/features/uploadDocument/handler.ts b/packages/documents/src/features/uploadDocument/handler.ts index fc860f6021f..a0028fb0689 100644 --- a/packages/documents/src/features/uploadDocument/handler.ts +++ b/packages/documents/src/features/uploadDocument/handler.ts @@ -31,15 +31,36 @@ export async function documentUploadHandler( const payload = request.payload as IDocumentPayload const ref = uuid() try { - const base64String = payload.fileData.split(',')[1] - const base64Decoded = Buffer.from(base64String, 'base64') - const fileType = (await fromBuffer(base64Decoded)) as IFileInfo - const generateFileName = `${ref}.${fileType.ext}` + // payload is an image + const regex = /^data:image/ + let generateFileName + if (regex.test(payload.fileData)) { + const base64String = payload.fileData.split(',')[1] + const base64Decoded = Buffer.from(base64String, 'base64') + const fileType = (await fromBuffer(base64Decoded)) as IFileInfo + generateFileName = `${ref}.${fileType.ext}` - await minioClient.putObject(MINIO_BUCKET, generateFileName, base64Decoded, { - 'content-type': fileType.mime, - ...payload.metaData - }) + await minioClient.putObject( + MINIO_BUCKET, + generateFileName, + base64Decoded, + { + 'content-type': fileType.mime, + ...payload.metaData + } + ) + } else { + // payload is an svg cert + const generateFileName = `${ref}.CERTIFICATE` + await minioClient.putObject( + MINIO_BUCKET, + generateFileName, + payload.fileData, + { + 'content-type': 'image/svg+xml' + } + ) + } return h .response({ refUrl: `/${MINIO_BUCKET}/${generateFileName}` }) diff --git a/yarn.lock b/yarn.lock index 071f9c97bc7..8b1aea1ca9e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -23937,9 +23937,9 @@ typescript@4.9.5, typescript@^4.5: integrity sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g== "typescript@>=3 < 6": - version "5.4.5" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.4.5.tgz#42ccef2c571fdbd0f6718b1d1f5e6e5ef006f611" - integrity sha512-vcI4UpRgg81oIRUFwR0WSIHKt11nJ7SAVlYNIu+QpqeyXP+gpQJy/Z4+F0aGxSE4MqwjyXvW/TzgkLAx2AGHwQ== + version "5.6.3" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.6.3.tgz#5f3449e31c9d94febb17de03cc081dd56d81db5b" + integrity sha512-hjcS1mhfuyi4WW8IWtjP7brDrG2cuDZukyrYrSauoXGNgx0S7zceP07adYkJycEr56BOUTNPzbInooiN3fn1qw== typical@^2.6.1: version "2.6.1"