我将 @UseInterceptors 与 @nestjs/platform-express 中的 FilesInterceptor 一起使用。FilesInterceptor 允许我传递一些配置(例如文件存储文件夹)。我想传递的不是精确值(例如“public”),而是从 configService 获取它们。
从这个答案(/sf/answers/4187966611/)我明白为什么从 UseInterceptors 调用 this.configService 会导致未定义。
@UseInterceptors(FilesInterceptor('cat_pic', 2, this.configService.get('storageConfigs')))
Run Code Online (Sandbox Code Playgroud)
那么如何将配置传递给 FilesInterceptor 呢?或者,如果我将文件拦截器功能移至单独的模块,如何访问服务?