evidence attachment system for reports

This commit is contained in:
2024-11-12 11:28:45 +01:00
parent 82bbf6dd8d
commit 9d25dd044f

View File

@@ -0,0 +1,23 @@
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"
})
}