Spaces:
Runtime error
Runtime error
| import { | |
| Controller, | |
| Get, | |
| Delete, | |
| Query, | |
| HttpCode, | |
| HttpStatus, | |
| } from '@nestjs/common'; | |
| import { ApiTags, ApiOperation, ApiQuery } from '@nestjs/swagger'; | |
| import { ImagekitioService } from './imagekitio.service'; | |
| import { FileType } from './enums/file-type.enum'; | |
| import { LogToDiscord } from 'src/shared/decorators/log-to-discord.decorator'; | |
| ('Upload: ImageKit.io Storage') | |
| ('imagekit') | |
| () | |
| export class ImagekitioController { | |
| constructor(private readonly imagekitioService: ImagekitioService) {} | |
| ('signed-upload') | |
| ({ summary: 'Get signed upload parameters' }) | |
| ({ name: 'type', enum: FileType, required: false }) | |
| getSignedUploadParams(('type') type?: FileType) { | |
| return this.imagekitioService.getAuthenticationParameters(type); | |
| } | |
| ('by-url') | |
| ({ summary: 'Get file details by URL' }) | |
| async getFileByUrl(('url') url: string): Promise<any> { | |
| return this.imagekitioService.getFileIdByUrl(url); | |
| } | |
| ('by-url') | |
| (HttpStatus.OK) | |
| ({ summary: 'Delete file by URL' }) | |
| async deleteFileByUrl(('url') url: string) { | |
| const result = await this.imagekitioService.deleteFileByUrl(url); | |
| return { | |
| message: 'File deleted successfully', | |
| ...result, | |
| }; | |
| } | |
| } | |