This commit is contained in:
2025-06-10 14:52:39 +02:00
parent bb1a237961
commit 8c0d8cae69
5 changed files with 136 additions and 114 deletions

View File

@@ -23,8 +23,8 @@ export default defineEventHandler(async (event) => {
});
}
// Ensure EOIs folder exists
await createBucketIfNotExists('nda-documents');
// Ensure bucket exists
await createBucketIfNotExists('client-portal');
// Parse multipart form data
const form = formidable({
@@ -55,15 +55,17 @@ export default defineEventHandler(async (event) => {
// Get content type
const contentType = mime.lookup(uploadedFile.originalFilename || '') || 'application/pdf';
// Upload to MinIO
await uploadFile(fileName, fileBuffer, contentType);
// Upload to MinIO client-portal bucket
const client = getMinioClient();
await client.putObject('client-portal', fileName, fileBuffer, fileBuffer.length, {
'Content-Type': contentType,
});
// Clean up temp file
await fs.unlink(uploadedFile.filepath);
// Get download URL for the uploaded file
const client = getMinioClient();
const url = await client.presignedGetObject('nda-documents', fileName, 24 * 60 * 60); // 24 hour expiry
const url = await client.presignedGetObject('client-portal', fileName, 24 * 60 * 60); // 24 hour expiry
// Prepare document data for database
const documentData = {