oa_based/src/modules/tools/upload/upload.dto.ts

28 lines
583 B
TypeScript
Raw Normal View History

2024-02-28 08:32:35 +08:00
import { MultipartFile } from '@fastify/multipart'
import { ApiProperty } from '@nestjs/swagger'
import { IsDefined } from 'class-validator'
import { IsFile } from './file.constraint'
export class FileUploadDto {
@ApiProperty({ type: Buffer, format: 'binary', description: '文件' })
@IsDefined()
@IsFile(
{
mimetypes: [
'image/png',
'image/gif',
'image/jpeg',
'image/webp',
'image/svg+xml',
],
fileSize: 1024 * 1024 * 10,
},
{
message: '文件类型不正确',
},
)
file: MultipartFile
}