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:
maulanasdqn
2026-04-10 14:24:18 +07:00
co-authored by Claude Opus 4.6
parent 651fd65ccb
commit 7268403ca4
2 changed files with 6 additions and 3 deletions
+4 -1
View File
@@ -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 };
},