File tree Expand file tree Collapse file tree 2 files changed +62
-24
lines changed
Expand file tree Collapse file tree 2 files changed +62
-24
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1+ import { ApiProperty } from '@nestjs/swagger' ;
2+ import { File } from '../../entity/file.entity' ;
3+
4+ export class FileUploadResponseDto {
5+ @ApiProperty ( {
6+ example : 1 ,
7+ description : '파일 ID' ,
8+ } )
9+ id : number ;
10+
11+ @ApiProperty ( {
12+ example : 'example.jpg' ,
13+ description : '원본 파일명' ,
14+ } )
15+ originalName : string ;
16+
17+ @ApiProperty ( {
18+ example : 'image/jpeg' ,
19+ description : '파일 MIME Type' ,
20+ } )
21+ mimetype : string ;
22+
23+ @ApiProperty ( {
24+ example : 1024000 ,
25+ description : '파일 크기 (bytes)' ,
26+ } )
27+ size : number ;
28+
29+ @ApiProperty ( {
30+ example : '/objects/profile/2024/01/example.jpg' ,
31+ description : '파일 접근 URL' ,
32+ } )
33+ url : string ;
34+
35+ @ApiProperty ( {
36+ example : 1 ,
37+ description : '업로드한 사용자 ID' ,
38+ } )
39+ userId : number ;
40+
41+ @ApiProperty ( {
42+ example : '2024-01-01T12:00:00.000Z' ,
43+ description : '업로드 날짜' ,
44+ } )
45+ createdAt : Date ;
46+
47+ private constructor ( partial : Partial < FileUploadResponseDto > ) {
48+ Object . assign ( this , partial ) ;
49+ }
50+
51+ static toResponseDto ( savedFile : File , accessUrl : string ) {
52+ return new FileUploadResponseDto ( {
53+ id : savedFile . id ,
54+ originalName : savedFile . originalName ,
55+ mimetype : savedFile . mimetype ,
56+ size : savedFile . size ,
57+ url : accessUrl ,
58+ userId : savedFile . user . id ,
59+ createdAt : savedFile . createdAt ,
60+ } ) ;
61+ }
62+ }
You can’t perform that action at this time.
0 commit comments