Skip to main content

Story 4: Student Document Management

Overview

FieldValue
Story IDNGE-13-4
Story Points13
SprintSprint 8

Technical Implementation

Document Upload Service

@Injectable()
export class DocumentService {
async uploadDocument(
studentId: string,
file: Express.Multer.File,
metadata: UploadDocumentDto,
) {
// Validate file
this.validateFile(file, metadata.documentType);

// Upload to S3 with encryption
const s3Key = `students/${studentId}/${metadata.documentType}/${file.originalname}`;
await this.s3.upload({
key: s3Key,
body: file.buffer,
serverSideEncryption: 'aws:kms',
});

// Save metadata
return this.prisma.studentDocument.create({
data: { studentId, documentType: metadata.documentType, s3Key }
});
}

async getSignedUrl(documentId: string) {
// Audit access (DPDPA compliance)
await this.auditService.log({ action: 'VIEW_DOCUMENT', documentId });

const doc = await this.prisma.studentDocument.findUnique({ where: { id: documentId } });
return this.s3.getSignedUrl(doc.s3Key, 300); // 5 min expiry
}
}

Document Types

TypeMax SizeFormats
PHOTO2MBJPEG, PNG
BIRTH_CERTIFICATE5MBPDF, JPEG
AADHAAR5MBPDF, JPEG
TC5MBPDF
MARKSHEET10MBPDF