export class UploadGreetingController {
constructor(
private greetingFacade: GreetingFacade,
) {}
@UseInterceptors(FileInterceptor('file', {
storage: diskStorage({
destination: (req: any, file, cb) => {
if (process.env.DEVELOPMENT === 'prod') {
return cb(null, `${process.env.DEV_PATH_TO_GREETING_AUDIO}`);
}
return cb(null, `${process.env.PROD_PATH_TO_GREETING_AUDIO}`);
},
filename: async (req: any, file, cb) => {
let uuid = await v4();
req.params.uuid = uuid;
return cb(null, `${uuid}.mp3`);
}
}),
fileFilter: async (req, file: any, cb) => {
let {userId, accountId} = req.user;
let {greetingID} = req.params;
if (greetingID === 'null' || !greetingID) {
req.params.error = 'greeting:youShouldPassGreetingID';
return cb(null, false);
}
//In this section, I need to access the value of this.greetingFacade. How can I achieve that?
let greetingEntity: any = await this.greetingFacade.getGreetingByUserIdAndAccountIdAndGreetingID(userId, accountId, greetingID);
let type = (req.params.type) ? req.params.type : greetingEntity.type;
if (type) {
let type = (typeof req.params.type === 'string') ? parseInt(req.params.type) : req.params.type;
if (type === 2) {
if (!file.originalname.match(/\.(mp3)$/)) {
return cb(null, false);
}
req.params.error = 'greeting:youShouldPassCorrectAudioFormat';
let deleteGreeting = (greetingEntity.uuid) ?
await this.greetingFacade.deleteAudioFromDisk(`${process.env.DEV_PATH_TO_GREETING_AUDIO}`, greetingEntity.uuid) : null;
return cb(null, file);
}
return cb(null, false);
}
return cb(null, false);
}
}))
}
The code above showcases my dilemma. I am trying to access the value of this.greetingFacade
. However, it is currently inaccessible within the @UseInterceptors
decorator. How can I make it accessible? It seems like I may need to modify or remove the
private greetingFacade: GreetingFacade
part of the code. Take a look at this specific code snippet for more context.
//HERE I WANT TO GET ACCESS TO this.greetingFacade .How can I make it ?