Spaces:
Runtime error
Runtime error
| import { | |
| Controller, | |
| Get, | |
| Delete, | |
| Query, | |
| HttpCode, | |
| HttpStatus, | |
| } from '@nestjs/common'; | |
| import { ApiTags, ApiOperation, ApiQuery } from '@nestjs/swagger'; | |
| import { CloudinaryService } from './cloudinary.service'; | |
| import { FileType } from './enums/file-type.enum'; | |
| import { LogToDiscord } from 'src/shared/decorators/log-to-discord.decorator'; | |
| ('Upload: Cloudinary Storage') | |
| ('cloudinary') | |
| () | |
| export class CloudinaryController { | |
| constructor(private readonly cloudinaryService: CloudinaryService) {} | |
| ('signed-upload') | |
| ({ summary: 'Get signed upload parameters' }) | |
| ({ name: 'type', enum: FileType, required: false }) | |
| ({ name: 'publicId', required: false }) | |
| getSignedUploadParams( | |
| ('type') type?: FileType, | |
| ('publicId') publicId?: string, | |
| ) { | |
| return this.cloudinaryService.getSignedUploadParams(type, publicId); | |
| } | |
| ('by-url') | |
| ({ summary: 'Get file details by URL' }) | |
| async getFileByUrl(('url') url: string) { | |
| return this.cloudinaryService.getFileDetailsByUrl(url); | |
| } | |
| ('by-url') | |
| (HttpStatus.OK) | |
| ({ summary: 'Delete file by URL' }) | |
| async deleteFileByUrl(('url') url: string) { | |
| const result = await this.cloudinaryService.deleteFileByUrl(url); | |
| return { | |
| message: 'File deleted successfully', | |
| ...result, | |
| }; | |
| } | |
| } | |