fixed the document type name inserting issue

This commit is contained in:
2025-11-29 16:13:15 +05:30
parent 8961e49dac
commit 5ad17869be
2 changed files with 12 additions and 11 deletions

View File

@@ -19,7 +19,7 @@ const s3 = new AWS.S3({
// Define uploadToS3 function with proper folder structure and file replacement
async function uploadToS3(buffer: Buffer, mimeType: string, originalName: string, folderType: 'profile' | 'documents', userId: number, documentType?: string) {
let s3Key: string;
// Sanitize file name: remove special characters and spaces
const sanitizeFileName = (name: string) => {
return name
@@ -31,7 +31,7 @@ async function uploadToS3(buffer: Buffer, mimeType: string, originalName: string
// Get file extension from original file name
const fileExtension = originalName.split('.').pop() || 'jpg';
// Determine folder structure based on type
if (folderType === 'profile') {
// Profile Images: MinglarAdmin/ProfileImages/{UserID}/profile_image.{extension}
@@ -84,7 +84,7 @@ export const handler = safeHandler(async (
// Parse multipart form data
const contentType = event.headers['Content-Type'] || event.headers['content-type'];
const isBase64Encoded = event.isBase64Encoded || false;
const { fields, files } = parseMultipartFormData(
event.body,
contentType,
@@ -102,7 +102,7 @@ export const handler = safeHandler(async (
const { address1, address2, stateXid, countryXid, cityXid, pinCode } = addressData;
// Handle file uploads with proper folder structure and replacement
const uploadedFiles: Array<{ fileName: string; filePath: string; documentType?: string }> = [];
const uploadedFiles: Array<{ fileName: string; filePath: string; documentType?: string, documentTypeName?: string }> = [];
let profileImagePath: string | undefined = profileImage;
// Upload profile image if provided as file
@@ -131,9 +131,9 @@ export const handler = safeHandler(async (
userId,
'aadhar'
);
uploadedFiles.push({
fileName: aadharFile.fileName,
filePath,
uploadedFiles.push({
fileName: aadharFile.fileName,
filePath,
documentType: 'aadhar',
documentTypeName: 'aadhar'
});
@@ -149,9 +149,9 @@ export const handler = safeHandler(async (
userId,
'pan'
);
uploadedFiles.push({
fileName: panFile.fileName,
filePath,
uploadedFiles.push({
fileName: panFile.fileName,
filePath,
documentType: 'pan',
documentTypeName: 'pan'
});
@@ -179,6 +179,7 @@ export const handler = safeHandler(async (
uploadedFiles.filter(f => f.documentType).map(f => ({
fileName: f.fileName,
filePath: f.filePath,
documentTypeName: f.documentTypeName,
}))
);

View File

@@ -416,7 +416,7 @@ export class MinglarService {
cityXid?: number;
pinCode?: string;
},
documents: Array<{ fileName: string; filePath: string }>,
documents: Array<{ fileName: string; filePath: string, documentTypeName?: string }>,
) {
try {
return await this.prisma.$transaction(async (tx) => {