Служба чтения внутри FileInterceptor nestjs - PullRequest
0 голосов
/ 02 апреля 2020

У меня есть место загрузки файла в классе FilesService

Теперь я хочу получить этот путь внутри FileInterceptor

 @UseInterceptors(FileInterceptor('file', {
        storage: diskStorage({
            destination: this.filesService.getFilePath()
            , filename: (req, file, cb) => {
                // Generating a 32 random chars long string
                const randomName = Array(32).fill(null).map(() => (Math.round(Math.random() * 16)).toString(16)).join('')
                //Calling the callback passing the random name generated with the original extension name
                cb(null, `${randomName}${extname(file.originalname)}`)
            }
        })
    }))

Но при перезапуске сервера я получаю сообщение об ошибке Не удается прочитать свойство 'getFilePath' из неопределенного

...