feat: add cloudinary image upload to project forms, fix project details gallery styling, add gallery preview to project list

This commit is contained in:
mstfyldz
2026-06-05 21:35:46 +03:00
parent 3794a70901
commit 1f1bb8d913
9 changed files with 157 additions and 10 deletions
+32
View File
@@ -0,0 +1,32 @@
import { NextRequest, NextResponse } from 'next/server'
import cloudinary from '@/lib/cloudinary'
export async function POST(request: NextRequest) {
try {
const formData = await request.formData()
const file = formData.get('file') as File
if (!file) {
return NextResponse.json({ error: 'Dosya bulunamadı.' }, { status: 400 })
}
// Convert file to buffer
const arrayBuffer = await file.arrayBuffer()
const buffer = Buffer.from(arrayBuffer)
const base64 = `data:${file.type};base64,${buffer.toString('base64')}`
// Upload to Cloudinary
const result = await cloudinary.uploader.upload(base64, {
folder: 'ayristech/projects',
transformation: [
{ width: 1200, crop: 'limit' },
{ quality: 'auto', fetch_format: 'auto' }
]
})
return NextResponse.json({ url: result.secure_url })
} catch (error) {
console.error('Upload error:', error)
return NextResponse.json({ error: 'Yükleme başarısız oldu.' }, { status: 500 })
}
}