import { ApiProperty } from '@nestjs/swagger';
import { IsIn, IsInt, Max, Min } from 'class-validator';
import { MEDIA_MAX_SIZE_BYTES } from '../../../common/media/allowed-media';
import {
  DIRECT_UPLOAD_FOLDERS,
  DIRECT_UPLOAD_MIME_TYPES,
  DirectUploadFolder,
  DirectUploadMimeType,
} from '../../../common/media/direct-upload.policy';

export class CreateDirectUploadDto {
  @ApiProperty({ enum: DIRECT_UPLOAD_FOLDERS, example: 'posts/video' })
  @IsIn(DIRECT_UPLOAD_FOLDERS)
  folder!: DirectUploadFolder;

  @ApiProperty({ enum: DIRECT_UPLOAD_MIME_TYPES, example: 'video/mp4' })
  @IsIn(DIRECT_UPLOAD_MIME_TYPES)
  mimeType!: DirectUploadMimeType;

  @ApiProperty({
    description: 'Exact number of bytes that will be sent in the PUT request',
    minimum: 1,
    maximum: MEDIA_MAX_SIZE_BYTES.postsVideo,
    example: 5242880,
  })
  @IsInt()
  @Min(1)
  @Max(MEDIA_MAX_SIZE_BYTES.postsVideo)
  size!: number;
}
