NestJS 서버에 있는 파일을 클라이언트로 전달하기 - 4
이제 서버에 있는 파일을 클라이언트가 다운받을수 있도록 API를 만들도록 하겠습니다. 이전글 : NestJS AWS S3버킷에 저장되어있는 파일을 서버에 저장하기 - 3: S3 Bucket의 파일을 다운로드 하기 import { Controller , Get , Query , Response , StreamableFile , } from '@nestjs/common' ; import { ApiQuery , ApiTags } from '@nestjs/swagger' ; import { createReadStream } from 'fs' ; import { join } from 'path' ; @ ApiTags ( '서버로부터 다운로드 받기' ) @ Controller ( 'download-file' ) export class DownloadFileController { @ Get () @ ApiQuery ({ name : 'fn' , description : '다운로드 받을 파일이름을 입력한다.(존재해야함)' , required : true , type : String , example : 'test.txt' , }) async download ( @ Query ( 'fn' ) fileName : string , @ Response ({ passthrough : true }) res , ): Promise < StreamableFile > { // 프로젝트 폴더 경로를 나타내 준다 console . log ( 'process.cwd() : ' , process . cwd ()); // stream file을 생성해 준다. const ...