fix: nahravanie velkych obrazkov - priamo do Supabase cez podpisanu URL, zmensenie na 2000 px

Vercel odmietal poziadavky nad 4,5 MB (Request Entity Too Large) a bucket
berie najviac 10 MB.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Jakub_HostacnyandClaude Opus 5.5 committed 2026-10-21 13:29:29 +02:00
1 parent 3ece5abf6a
commit 17c852e2bf
4 files changed
+76 -49

No files matched your search

+4 -15
View File
@@ -2,6 +2,7 @@
import React, { useRef, useState } from 'react';
import { Upload, Loader2, Image as ImageIcon } from 'lucide-react';
import { shrinkImage, uploadFile } from '@/lib/upload';
interface ImageUploadInputProps {
label?: string;
@@ -32,22 +33,10 @@ export const ImageUploadInput: React.FC<ImageUploadInputProps> = ({
setIsUploading(true);
try {
const formData = new FormData();
formData.append('file', file);
const res = await fetch('/api/upload', {
method: 'POST',
body: formData
});
const data = await res.json();
if (data.success && data.url) {
onChange(data.url);
} else {
alert(`Chyba pri nahrávaní obrázka: ${data.error || 'Neznáma chyba'}`);
}
const small = await shrinkImage(file);
onChange(await uploadFile(small, small.name));
} catch (err: any) {
alert(`Chyba: ${err.message}`);
alert(`Chyba pri nahrávaní obrázka: ${err.message}`);
} finally {
setIsUploading(false);
if (fileInputRef.current) {