| Conditions | 3 | 
| Total Lines | 16 | 
| Code Lines | 14 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 0 | ||
| 1 | import {Inject} from '@nestjs/common'; | ||
| 17 | |||
| 18 |   public async execute(query: DownloadFileQuery): Promise<DownloadedFileView> { | ||
| 19 | const file = await this.fileRepository.findOneById(query.id); | ||
| 20 |     if (!file) { | ||
| 21 | throw new FileNotFoundException(); | ||
| 22 | } | ||
| 23 | |||
| 24 | const buffer = await this.fileStorage.download(file); | ||
| 25 |     if (!buffer) { | ||
| 26 | throw new FileNotFoundException(); | ||
| 27 | } | ||
| 28 | |||
| 29 | return new DownloadedFileView( | ||
| 30 | file.getOriginalName(), | ||
| 31 | file.getMimeType(), | ||
| 32 | buffer | ||
| 33 | ); | ||
| 36 |