24.06.09 03:59 작성
·
101
0
@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/ 이 링크에서 코드 이미지로 다운로드 후 업로드 해주셔도 괜찮습니다.
감사합니다!