Loading...
Loading...
Loading...
// next.config.ts
export default {
experimental: {
serverActions: {
bodySizeLimit: '10mb',
},
},
};// next.config.ts
export default {
images: {
remotePatterns: [
{ protocol: 'https', hostname: 'your-bucket.s3.amazonaws.com' },
{ protocol: 'https', hostname: 'res.cloudinary.com' },
],
},
};// app/api/upload/route.ts
export async function POST(request: Request) {
const formData = await request.formData();
const file = formData.get('file') as File;
const bytes = await file.arrayBuffer();
const buffer = Buffer.from(bytes);
// save to disk / upload to S3 / Cloudinary
}// ตัวอย่าง Vercel Blob
import { put } from '@vercel/blob';
const blob = await put(file.name, file, {
access: 'public',
});
// blob.url → URL ของไฟล์ที่ upload แล้ว