인프런 커뮤니티 질문&답변

임상현님의 프로필 이미지

작성한 질문수

[코드팩토리] [초급] NestJS REST API 백엔드 완전 정복 마스터 클래스 - NestJS Core

FileInterceptor 적용하기

섹션26 FileIntercepter 업로드 파일 질문

24.06.09 03:59 작성

·

101

0

다른것은 다 문제가 없다만, 업로드 public/post파일에 이미지가 안들어옵니다일부러 폴더이름과 변수명은 다르게 했습니다@Module({ imports: [ TypeOrmModule.forFeature([Event]), MulterModule.register({ fileFilter: (_req, file, cb) => { extname(file.originalname) return cb(null, true) }, storage: multer.diskStorage({ destination: (_req, _res, cb) => { cb(null, EVENT_IMG_PATH) }, // 파일 이름이 겹치지않게 고유한 uuid값을 이미지 고유 이름 앞에 붙여줌 filename: (_req, file, cb) => { cb(null, `${uuid()}${extname(file.originalname)}`) } }) }) ], controllers: [EventController], providers: [EventService] }) export class EventModule {} import { join } from 'path' //서버 프로잭트 루트 폴더 export const ROOT_PATH = process.cwd() // 외부에서 접근가능한 파일들 모아둔 폴더 이름 export const PUBLIC_FOLDER_NAME = 'upload' //위클 이벤트 사진들이 저장된 폴더 이름 export const EVENT_FOLDER_NAME = 'event' //실제 공개폴더의 실제 위치 export const PUBLIC_FOLDER_PATH = join( ROOT_PATH, PUBLIC_FOLDER_NAME ) //위클 이미지를 저장할 폴더 export const EVENT_IMG_PATH = join( PUBLIC_FOLDER_PATH, EVENT_FOLDER_NAME ) // upload/event/이미지 export const EVENT_PUBLIC_IMG_PATH = join( PUBLIC_FOLDER_NAME, EVENT_FOLDER_NAME )

답변 1

0

코드팩토리님의 프로필 이미지
코드팩토리
지식공유자

2024. 06. 10. 11:31

안녕하세요!

강의 그대로 하면 잘 되지만 특정 코드를 변경하면 잘 안된다는 말씀이 맞으실까요?

코드를 정리해서 어떤 부분을 변경했는지 정확히 보여주시면 함께 확인 해드리겠습니다.

보여주신 코드는 도저히 읽을수가 없습니다.

IDE에서 그대로 복사해서 붙여넣기하면 생긴 그대로 코드가 입력됩니다.

또는 https://carbon.now.sh/ 이 링크에서 코드 이미지로 다운로드 후 업로드 해주셔도 괜찮습니다.

감사합니다!