23 lines
844 B
TypeScript
23 lines
844 B
TypeScript
import type { NextApiRequest, NextApiResponse } from "next"
|
|
|
|
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
|
|
if (req.method !== "POST") return res.status(405).json({ error: "Method not allowed" })
|
|
|
|
// Simple file handling simulation - in real app would use storage service
|
|
const { file_data, file_name, report_id } = req.body
|
|
|
|
if (!file_data || !file_name || !report_id) {
|
|
return res.status(400).json({ error: "Missing required fields" })
|
|
}
|
|
|
|
// Validate file type and size
|
|
const allowedTypes = ['image/jpeg', 'image/png', 'image/gif', 'application/pdf']
|
|
const maxSize = 5 * 1024 * 1024 // 5MB
|
|
|
|
// In real implementation, save to storage and store metadata in DB
|
|
res.json({
|
|
success: true,
|
|
attachment_id: Date.now(),
|
|
message: "Attachment uploaded successfully"
|
|
})
|
|
} |