diff --git a/functions/api/avatars/index.js b/functions/api/avatars/index.js index ef1e7cb..58e7401 100644 --- a/functions/api/avatars/index.js +++ b/functions/api/avatars/index.js @@ -19,8 +19,9 @@ export async function onRequestPut(context) { return createErrorResponse("Missing avatar", 400); } - if (avatar.size > 2 * 1024 * 1024) { - return createErrorResponse("Avatar must be less than 2MB", 400); + if (avatar.size > 1 * 1024 * 1024) { + // Entity too large + return createErrorResponse("Avatar must be less than 1MB", 413); } const buffer = await avatar.arrayBuffer(); diff --git a/src/components/Profile/ProfileForm.vue b/src/components/Profile/ProfileForm.vue index 1bca836..4ddd1f3 100644 --- a/src/components/Profile/ProfileForm.vue +++ b/src/components/Profile/ProfileForm.vue @@ -25,17 +25,17 @@ const onSubmit = async () => { avatarError.value = ''; if (!avatarFile.value) { - avatarError.value = 'Avatar is required.'; + avatarError.value = '必須選擇新頭貼。'; return; } - if (avatarFile.value.size > 2 * 1024 * 1024) { - avatarError.value = 'Avatar must be less than 2MB.'; + if (avatarFile.value.size > 1 * 1024 * 1024) { + avatarError.value = '頭貼檔案需小於 1MB。'; return; } if (avatarFile.value.type !== 'image/jpeg' && avatarFile.value.type !== 'image/png') { - avatarError.value = 'Avatar must be a JPG or PNG image.'; + avatarError.value = '頭貼必須是 JPG 或 PNG 格式。'; return; } @@ -72,7 +72,7 @@ const avatarUrl = computed(() => {