Skip to content

Commit

Permalink
test file upload on develop
Browse files Browse the repository at this point in the history
Signed-off-by: tipusinghaw <tipu.singh@ayanworks.com>
Signed-off-by: KulkarniShashank <shashank.kulkarni@ayanworks.com>
  • Loading branch information
tipusinghaw authored and KulkarniShashank committed Sep 11, 2024
1 parent d4a7cb6 commit d516ba1
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 5 deletions.
6 changes: 4 additions & 2 deletions apps/api-gateway/src/issuance/issuance.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -292,10 +292,12 @@ async downloadBulkIssuanceCSVTemplate(
): Promise<object> {
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);
Expand Down
33 changes: 30 additions & 3 deletions apps/issuance/src/issuance.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -982,11 +982,38 @@ async sendEmailForCredentialOffer(sendEmailCredentialOffer: SendEmailCredentialO

async uploadCSVTemplate(importFileDetails: ImportFileDetails, requestId?: string): Promise<string> {
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, {
Expand Down

0 comments on commit d516ba1

Please sign in to comment.