From 0b1c7f7ed430de4b16d3f25048db43f168275c20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Skyler=20M=C3=A4ntysaari?= Date: Thu, 2 Feb 2023 12:36:55 +0200 Subject: [PATCH] feat(web): Helper for raw image type. --- web/src/lib/utils/file-uploader.ts | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/web/src/lib/utils/file-uploader.ts b/web/src/lib/utils/file-uploader.ts index 30cd19fa5e..0d619bee76 100644 --- a/web/src/lib/utils/file-uploader.ts +++ b/web/src/lib/utils/file-uploader.ts @@ -46,7 +46,7 @@ export const fileUploadHandler = async ( if (files.length > 50) { notificationController.show({ type: NotificationType.Error, - message: `Cannot upload more than 50 files at a time - you are uploading ${files.length} files. + message: `Cannot upload more than 50 files at a time - you are uploading ${files.length} files. Please check out the bulk upload documentation if you need to upload more than 50 files.`, timeout: 10000, action: { type: 'link', target: 'https://immich.app/docs/features/bulk-upload' } @@ -93,12 +93,7 @@ async function fileUploader( formData.append('deviceId', 'WEB'); // Get asset type - if (fileExtension.toLowerCase() == 'raf' || fileExtension.toLowerCase() == 'srw') { - // Workaround for annoying RAW types. - formData.append('assetType', 'IMAGE'); - } else { - formData.append('assetType', assetType); - } + formData.append('assetType', isRawImageType(fileExtension) || assetType); // Get Asset Created Date formData.append('createdAt', createdAt); @@ -197,6 +192,14 @@ async function fileUploader( } } +function isRawImageType(fileExtension: string): string | null { + const RAW_TYPES = ['raf', 'srw']; + if (RAW_TYPES.includes(fileExtension.toLowerCase())) { + return 'IMAGE'; + } + return null; +} + function handleUploadError(asset: File, respBody = '{}', extraMessage?: string) { try { const res = JSON.parse(respBody);