Skip to content

Commit

Permalink
wip: implement upload logo on s3 bucket functionaity
Browse files Browse the repository at this point in the history
Signed-off-by: bhavanakarwade <[email protected]>
Signed-off-by: KulkarniShashank <[email protected]>
  • Loading branch information
bhavanakarwade authored and KulkarniShashank committed Sep 11, 2024
1 parent 77b8ec2 commit 6362cbe
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 13 deletions.
13 changes: 2 additions & 11 deletions apps/organization/src/organization.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { PrismaService } from '@credebl/prisma-service';
import { CommonService } from '@credebl/common';
import { OrganizationRepository } from '../repositories/organization.repository';
import { ClientProxy, RpcException } from '@nestjs/microservices';
import { Inject } from '@nestjs/common';
import { Inject, NotFoundException } from '@nestjs/common';
import { OrgRolesService } from '@credebl/org-roles';
import { OrgRoles } from 'libs/org-roles/enums';
import { UserOrgRolesService } from '@credebl/user-org-roles';
Expand All @@ -16,7 +16,6 @@ import { sendEmail } from '@credebl/common/send-grid-helper-file';
import { CreateOrganizationDto } from '../dtos/create-organization.dto';
import { BulkSendInvitationDto } from '../dtos/send-invitation.dto';
import { UpdateInvitationDto } from '../dtos/update-invitation.dt';
import { NotFoundException } from '@nestjs/common';
import { Invitation, OrgAgentType, transition } from '@credebl/enum/enum';
import { IGetOrgById, IGetOrganization, IUpdateOrganization, IOrgAgent } from '../interfaces/organization.interface';
import { UserActivityService } from '@credebl/user-activity';
Expand Down Expand Up @@ -62,9 +61,6 @@ export class OrganizationService {
createOrgDto.createdBy = userId;
createOrgDto.lastChangedBy = userId;

// const imageUrl = await this.awsService.uploadUserCertificate(createOrgDto.logo, 'certificates', process.env.AWS_PUBLIC_BUCKET_NAME,
// 'base64');

const allowedExtensions = ['png', 'jpg', 'jpeg'];

const imageUrl = await this.uploadFileToS3(createOrgDto.logo, allowedExtensions);
Expand Down Expand Up @@ -93,7 +89,7 @@ export class OrganizationService {
try {
const ext = allowedExtensions.find(extension => orgLogo.endsWith(`.${extension}`)) || 'png';
const imgData = Buffer.from(orgLogo, 'base64');

// const imageData = converBase64ToImage(base64, pathToSaveImage)
// const logoUrl = await this.awsService.uploadUserCertificate(imgData, ext, 'orgLogo', process.env.AWS_ORG_LOGO_BUCKET_NAME,
// 'base64', 'orgLogos');
const logoUrl = await this.awsService.uploadUserCertificate(
Expand All @@ -104,11 +100,6 @@ export class OrganizationService {
'base64',
'orgLogos'
);

// const timestamp = Date.now();
// const filename = 'orgLogo';
// const pathAWS = '';
// const logoUrl = `https://${process.env.AWS_ORG_LOGO_BUCKET_NAME}.s3.${process.env.AWS_PUBLIC_REGION}.amazonaws.com/${pathAWS}/${encodeURIComponent(filename)}.${timestamp}.${ext}`;
return logoUrl;
} catch (error) {
this.logger.error(`In getting imageUrl : ${JSON.stringify(error)}`);
Expand Down
4 changes: 2 additions & 2 deletions libs/aws/src/aws.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ export class AwsService {
await putObjectAsync({
Bucket: bucketName,
// Bucket: process.env.AWS_PUBLIC_BUCKET_NAME,
Key: `${pathAWS}/${encodeURIComponent(filename)}-${timestamp}.${ext}`,
Key: `${pathAWS}/${encodeURIComponent(filename)}-${timestamp}.png`,
Body: fileBuffer,
ContentEncoding: encoding,
ContentType: `image/${ext}`
ContentType: `image/png`
// ContentType: ext
});

Expand Down

0 comments on commit 6362cbe

Please sign in to comment.