From d516ba171032bb03280966950533d46e2277eb96 Mon Sep 17 00:00:00 2001 From: tipusinghaw Date: Wed, 26 Jun 2024 13:53:48 +0530 Subject: [PATCH] test file upload on develop Signed-off-by: tipusinghaw Signed-off-by: KulkarniShashank --- .../src/issuance/issuance.controller.ts | 6 ++-- apps/issuance/src/issuance.service.ts | 33 +++++++++++++++++-- 2 files changed, 34 insertions(+), 5 deletions(-) diff --git a/apps/api-gateway/src/issuance/issuance.controller.ts b/apps/api-gateway/src/issuance/issuance.controller.ts index 7b3d08718..1fd591c89 100644 --- a/apps/api-gateway/src/issuance/issuance.controller.ts +++ b/apps/api-gateway/src/issuance/issuance.controller.ts @@ -292,10 +292,12 @@ async downloadBulkIssuanceCSVTemplate( ): Promise { if (file) { const fileKey: string = uuidv4(); + this.logger.log("file?.buffer:", file?.buffer); try { - + this.logger.log("fileKey:", fileKey); await this.awsService.uploadCsvFile(fileKey, file?.buffer); - + const temp = await this.awsService.getFile(fileKey); + this.logger.log("temp:", temp); } catch (error) { throw new RpcException(error.response ? error.response : error); diff --git a/apps/issuance/src/issuance.service.ts b/apps/issuance/src/issuance.service.ts index ba3c3238a..8bdc7671c 100644 --- a/apps/issuance/src/issuance.service.ts +++ b/apps/issuance/src/issuance.service.ts @@ -982,11 +982,38 @@ async sendEmailForCredentialOffer(sendEmailCredentialOffer: SendEmailCredentialO async uploadCSVTemplate(importFileDetails: ImportFileDetails, requestId?: string): Promise { try { - - const credDefResponse = - await this.issuanceRepository.getCredentialDefinitionDetails(importFileDetails.credDefId); + let credentialDetails; + const credentialPayload: ICredentialPayload = { + schemaLedgerId: '', + credentialDefinitionId: '', + fileData: {}, + fileName: '', + credentialType: '', + schemaName: '' + }; + const {fileName, templateId, type} = importFileDetails; + this.logger.log("importFileDetails:", importFileDetails); + if (type === SchemaType.W3C_Schema) { + credentialDetails = + await this.issuanceRepository.getSchemaDetailsBySchemaIdentifier(templateId); + credentialPayload.schemaLedgerId = credentialDetails.schemaLedgerId; + credentialPayload.credentialDefinitionId = SchemaType.W3C_Schema; + credentialPayload.credentialType = SchemaType.W3C_Schema; + credentialPayload.schemaName = credentialDetails.name; + + } else if (type === SchemaType.INDY) { + + credentialDetails = + await this.issuanceRepository.getCredentialDefinitionDetails(templateId); + credentialPayload.schemaLedgerId = credentialDetails.schemaLedgerId; + credentialPayload.credentialDefinitionId = credentialDetails.credentialDefinitionId; + credentialPayload.credentialType = SchemaType.INDY; + credentialPayload.schemaName = credentialDetails.schemaName; + this.logger.log("credentialDetails:", credentialDetails); + } const getFileDetails = await this.awsService.getFile(importFileDetails.fileKey); + this.logger.log("getFileDetails:", getFileDetails); const csvData: string = getFileDetails.Body.toString(); const parsedData = paParse(csvData, {