Skip to content

Commit

Permalink
update max file upload and change file upload on update campaignAppli…
Browse files Browse the repository at this point in the history
…cation
  • Loading branch information
Martbul committed Jul 26, 2024
1 parent 4a1e5a3 commit fc3aa3d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export class CampaignApplicationController {

@Patch(':id')
@UseInterceptors(
FilesInterceptor('file', 10, {
FilesInterceptor('file', 100, {
limits: { fileSize: 1024 * 1024 * 30 },
fileFilter: (_req: Request, file, cb) => {
validateFileType(file, cb)
Expand Down
18 changes: 2 additions & 16 deletions apps/api/src/campaign-application/campaign-application.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,9 @@ export class CampaignApplicationService {
personId: string,
updateCampaignApplicationDto: UpdateCampaignApplicationDto,
isAdminFlag: boolean,
organaizerId?: string,
organizerId?: string,
files?: Express.Multer.File[],
) {
console.log(id)

const campaignApplication = await this.prisma.campaignApplication.findUnique({
where: { id },
})
Expand All @@ -112,7 +110,7 @@ export class CampaignApplicationService {
throw new NotFoundException('Campaign application doesnt exist')
}

if (isAdminFlag == false && organaizerId !== campaignApplication.organizerId) {
if (isAdminFlag == false && organizerId !== campaignApplication.organizerId) {
throw new ForbiddenException('User is not organizer of the campaignApplication')
}

Expand Down Expand Up @@ -167,18 +165,6 @@ export class CampaignApplicationService {
}

if (files) {
const existingCampaignApplicationFiles = await this.prisma.campaignApplicationFile.findMany({
where: { campaignApplicationId: id },
})

for (const file of existingCampaignApplicationFiles) {
await this.s3.deleteObject(this.bucketName, file.id)
}

await this.prisma.campaignApplicationFile.deleteMany({
where: { campaignApplicationId: id },
})

await Promise.all(
files.map((file) => {
return this.campaignApplicationFilesCreate(file, personId, campaignApplication.id)
Expand Down

0 comments on commit fc3aa3d

Please sign in to comment.