fix: add image upload size limits for hackathon (#63)
- useUploadFile: add 5MB limit + image type validation for team logo/banner uploads (was unrestricted) - useUploadAvatar: tighten limit from 5MB to 2MB per issue request - Submit page: switch from useUploadFile to useUploadSubmission which has proper 50MB limit + broader file type support Size limits: - Profile avatar: 2MB (JPEG, PNG, WebP, GIF) - Team logo/banner: 5MB (JPEG, PNG, WebP, GIF) - Team files: 20MB (images + PDF) - Submissions: 50MB (images, PDF, ZIP, video) Closes #63 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
651fd65ccb
commit
7268403ca4
@@ -9,7 +9,7 @@ import {
|
||||
useSubmitProject,
|
||||
useTeamById,
|
||||
useTeamSubmission,
|
||||
useUploadFile,
|
||||
useUploadSubmission,
|
||||
useAuthStore,
|
||||
} from '@imphnen-frontend-service/service';
|
||||
import { zodResolver } from '@hookform/resolvers/zod';
|
||||
@@ -67,7 +67,7 @@ const SubmitProjectPage: FC = (): ReactElement => {
|
||||
const { data: submissionData } = useTeamSubmission(teamId || '', !!teamId);
|
||||
const { mutateAsync: submitProject, isPending: isSubmitting } =
|
||||
useSubmitProject(teamId || '');
|
||||
const { mutateAsync: uploadFile, isPending: isUploading } = useUploadFile();
|
||||
const { mutateAsync: uploadFile, isPending: isUploading } = useUploadSubmission();
|
||||
|
||||
const team = teamData?.data;
|
||||
const currentUserId = session?.user?.id;
|
||||
|
||||
@@ -14,6 +14,9 @@ export const useUploadFile = () => {
|
||||
mutationKey: ['upload-file'],
|
||||
mutationFn: async (file: File) => {
|
||||
if (!session?.user?.id) throw new Error('You must be logged in to upload files');
|
||||
const allowedTypes = ['image/jpeg', 'image/jpg', 'image/png', 'image/webp', 'image/gif'];
|
||||
if (!allowedTypes.includes(file.type)) throw new Error('Invalid file type. Allowed: JPEG, PNG, WebP, GIF');
|
||||
if (file.size > 5 * 1024 * 1024) throw new Error('File too large. Maximum size: 5MB');
|
||||
const data = await uploadHackathonTeamFile(file);
|
||||
return { data };
|
||||
},
|
||||
@@ -28,7 +31,7 @@ export const useUploadAvatar = () => {
|
||||
if (!session?.user?.id) throw new Error('You must be logged in to upload avatar');
|
||||
const allowedTypes = ['image/jpeg', 'image/jpg', 'image/png', 'image/webp', 'image/gif'];
|
||||
if (!allowedTypes.includes(file.type)) throw new Error('Invalid file type. Allowed: JPEG, PNG, WebP, GIF');
|
||||
if (file.size > 5 * 1024 * 1024) throw new Error('File too large. Maximum size: 5MB');
|
||||
if (file.size > 2 * 1024 * 1024) throw new Error('File too large. Maximum size: 2MB');
|
||||
const data = await uploadHackathonAvatar(file);
|
||||
return { data };
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user