diff --git a/src/components/pages/create-group/fields/images-field/image-loading-bar/index.tsx b/src/components/pages/create-group/fields/images-field/image-loading-bar/index.tsx new file mode 100644 index 00000000..8df34e37 --- /dev/null +++ b/src/components/pages/create-group/fields/images-field/image-loading-bar/index.tsx @@ -0,0 +1,22 @@ +export const ImageLoadingBar = () => { + return ( +
최대 3개까지 업로드할 수 있어요.
diff --git a/src/components/ui/hint/index.tsx b/src/components/ui/hint/index.tsx index ff10b39c..cbe1777c 100644 --- a/src/components/ui/hint/index.tsx +++ b/src/components/ui/hint/index.tsx @@ -8,7 +8,10 @@ export const Hint = ({ className, message, ...props }: HintProps) => { return (
{message}
diff --git a/src/lib/constants/image.ts b/src/lib/constants/image.ts
index ac267a6b..c9bd3d02 100644
--- a/src/lib/constants/image.ts
+++ b/src/lib/constants/image.ts
@@ -1,5 +1,5 @@
export const IMAGE_CONFIG = {
- maxSizeBytes: 20971520, // 20MB
+ maxSizeBytes: 10485760, // 10MB
maxWidth: 2000,
maxHeight: 2000,
allowedTypes: ['image/jpeg', 'image/png', 'image/webp'],
diff --git a/src/lib/validateImage.ts b/src/lib/validateImage.ts
index e03ffa0a..454d9c80 100644
--- a/src/lib/validateImage.ts
+++ b/src/lib/validateImage.ts
@@ -1,11 +1,14 @@
import { IMAGE_CONFIG } from './constants/image';
export const validateImage = async (file: File): Promise<{ valid: boolean; error?: string }> => {
- // 1. 확장자 검증
+ // 1. 파일 확장자 & 파일 타입 검증
const fileName = file.name.toLowerCase();
const hasValidExtension = IMAGE_CONFIG.allowedExtensions.some((ext) => fileName.endsWith(ext));
+ const hasValidType = IMAGE_CONFIG.allowedTypes.some((type) => file.type === type);
- if (!hasValidExtension) {
+ const isValidImage = hasValidExtension && hasValidType;
+
+ if (!isValidImage) {
return {
valid: false,
error: `파일 확장자가 올바르지 않습니다. \n(${IMAGE_CONFIG.allowedExtensions.join(', ')}만 가능)`,
@@ -17,7 +20,7 @@ export const validateImage = async (file: File): Promise<{ valid: boolean; error
const currentSizeMB = (file.size / (1024 * 1024)).toFixed(0);
return {
valid: false,
- error: `이미지 크기가 너무 큽니다. 최대 20MB까지 가능합니다. \n현재: ${currentSizeMB}MB`,
+ error: `이미지 크기가 너무 큽니다. 최대 10MB까지 가능합니다. \n현재: ${currentSizeMB}MB`,
};
}
diff --git a/src/types/service/common.ts b/src/types/service/common.ts
index fc64f79b..221e7c85 100644
--- a/src/types/service/common.ts
+++ b/src/types/service/common.ts
@@ -16,5 +16,3 @@ export class CommonSuccessResponse