-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #83 from boostcampwm2023/feat/67-convert-stream-to…
…-buffer [Feat] 스트림 파일에 대해 StreamableFile 반환 기능 구현
- Loading branch information
Showing
8 changed files
with
48 additions
and
14 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,26 @@ | ||
import { Controller, Get } from "@nestjs/common"; | ||
import { | ||
Controller, | ||
Get, | ||
Header, | ||
InternalServerErrorException, | ||
StreamableFile, | ||
} from "@nestjs/common"; | ||
import { IntroduceService } from "./introduce.service"; | ||
|
||
@Controller("introduce") | ||
export class IntroduceController { | ||
constructor(private introduceService: IntroduceService) {} | ||
|
||
@Get() | ||
async getIntroduceVideo(): Promise<object> { | ||
return this.introduceService.getIntroduceVideo(); | ||
@Header("Content-Type", "video/mp4") | ||
async getIntroduceVideo(): Promise<StreamableFile> { | ||
const stream = await this.introduceService.getIntroduceVideo(); | ||
try { | ||
return new StreamableFile(stream); | ||
} catch (error) { | ||
throw new InternalServerErrorException( | ||
"파일을 읽어오는 도중 서버에서 문제가 발생했습니다.", | ||
); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
import { Injectable } from "@nestjs/common"; | ||
import { Injectable, StreamableFile } from "@nestjs/common"; | ||
import { getFileFromS3 } from "src/utils/e3"; | ||
import { Readable } from "stream"; | ||
|
||
@Injectable() | ||
export class IntroduceService { | ||
async getIntroduceVideo(): Promise<object> { | ||
async getIntroduceVideo(): Promise<Readable> { | ||
return getFileFromS3("test.mp4"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters