feat: improve error messages for user upload size validation

This commit is contained in:
Kirill
2026-05-15 20:19:00 +05:00
parent d73d88d034
commit dc448d6538
3 changed files with 14 additions and 1 deletions
@@ -1,4 +1,5 @@
import { apiClient } from '@/shared/api/client'
import { OTHER_UPLOAD_MAX_FILE_BYTES, formatOtherUploadMaxSizeHint } from '@/shared/constants/upload-limits'
export async function postProductReview(
productId: string,
@@ -8,6 +9,10 @@ export async function postProductReview(
}
export async function uploadReviewImage(file: File): Promise<{ url: string }> {
if (file.size > OTHER_UPLOAD_MAX_FILE_BYTES) {
throw new Error(`Файл «${file.name}» слишком большой (максимум ${formatOtherUploadMaxSizeHint()}).`)
}
const fd = new FormData()
fd.append('file', file, file.name)
const { data } = await apiClient.post<{ url: string }>('reviews/upload-image', fd)