fix: increase upload limit to 15MB and fix infinite loading with S3 timeouts
This commit is contained in:
@@ -98,8 +98,8 @@ export default function EditProject({ params }: { params: { id: string } }) {
|
||||
}, [params.id, error, router]);
|
||||
|
||||
const uploadFile = async (file: File): Promise<UploadedImage | null> => {
|
||||
if (file.size > 2 * 1024 * 1024) {
|
||||
error('Arquivo maior que 2MB. Escolha uma imagem menor.');
|
||||
if (file.size > 15 * 1024 * 1024) {
|
||||
error('Arquivo maior que 15MB. Escolha uma imagem menor.');
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -413,7 +413,7 @@ export default function EditProject({ params }: { params: { id: string } }) {
|
||||
<p className="text-gray-600 dark:text-gray-300 font-medium mb-1">
|
||||
{uploadingCover ? 'Enviando imagem...' : 'Clique para fazer upload ou arraste e solte'}
|
||||
</p>
|
||||
<p className="text-xs text-gray-400">PNG, JPG ou WEBP (máximo 2MB)</p>
|
||||
<p className="text-xs text-gray-400">PNG, JPG ou WEBP (máximo 15MB)</p>
|
||||
</div>
|
||||
)}
|
||||
<input
|
||||
|
||||
@@ -49,8 +49,8 @@ export default function NewProject() {
|
||||
const isSaving = loading || uploadingCover || uploadingGallery;
|
||||
|
||||
const uploadFile = async (file: File): Promise<UploadedImage | null> => {
|
||||
if (file.size > 2 * 1024 * 1024) {
|
||||
error('Arquivo maior que 2MB. Escolha uma imagem menor.');
|
||||
if (file.size > 15 * 1024 * 1024) {
|
||||
error('Arquivo maior que 15MB. Escolha uma imagem menor.');
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -354,7 +354,7 @@ export default function NewProject() {
|
||||
<p className="text-gray-600 dark:text-gray-300 font-medium mb-1">
|
||||
{uploadingCover ? 'Enviando imagem...' : 'Clique para fazer upload ou arraste e solte'}
|
||||
</p>
|
||||
<p className="text-xs text-gray-400">PNG, JPG ou WEBP (máximo 2MB)</p>
|
||||
<p className="text-xs text-gray-400">PNG, JPG ou WEBP (máximo 15MB)</p>
|
||||
</div>
|
||||
)}
|
||||
<input
|
||||
|
||||
@@ -2,7 +2,17 @@ import { NextResponse } from 'next/server';
|
||||
import { minioClient, bucketName, ensureBucketExists } from '@/lib/minio';
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
|
||||
export const maxDuration = 60; // 60 segundos
|
||||
export const config = {
|
||||
api: {
|
||||
bodyParser: {
|
||||
sizeLimit: '15mb',
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export async function POST(request: Request) {
|
||||
console.log('📤 Recebendo upload de arquivo...');
|
||||
try {
|
||||
await ensureBucketExists();
|
||||
|
||||
|
||||
@@ -15,6 +15,8 @@ console.log(`[S3/MinIO] Configurando cliente: ${endpointUrl} (SSL: ${useSSL})`);
|
||||
|
||||
export const bucketName = process.env.S3_BUCKET_NAME || process.env.MINIO_BUCKET_NAME || 'occto-images';
|
||||
|
||||
import { NodeHttpHandler } from '@smithy/node-http-handler';
|
||||
|
||||
export const s3Client = new S3Client({
|
||||
region: 'us-east-1',
|
||||
endpoint: endpointUrl,
|
||||
@@ -23,6 +25,10 @@ export const s3Client = new S3Client({
|
||||
accessKeyId: process.env.S3_ACCESS_KEY || process.env.MINIO_ACCESS_KEY || 'admin',
|
||||
secretAccessKey: process.env.S3_SECRET_KEY || process.env.MINIO_SECRET_KEY || 'adminpassword',
|
||||
},
|
||||
requestHandler: new NodeHttpHandler({
|
||||
connectionTimeout: 10000, // 10 segundos
|
||||
socketTimeout: 10000, // 10 segundos
|
||||
}),
|
||||
});
|
||||
|
||||
type MetadataMap = Record<string, string> | undefined;
|
||||
|
||||
Reference in New Issue
Block a user