Closed mubasshir closed 4 years ago
Can you please show me how you imported the module?
app.module.ts
MulterExtendedModule.registerAsync({
useFactory: (config: ConfigService) => config.get('s3'),
inject: [ConfigService],
}),
config/s3.ts
export default {
accessKeyId: process.env.S3_ACCESS_KEY,
secretAccessKey: process.env.S3_ACCESS_SECRET,
region: process.env.S3_REGION,
bucket: process.env.S3_BUCKET,
fileSize: +process.env.S3_MAX_FILE_LIMIT * 1024 * 1024,
acl: 'public-read',
};
users.controller.ts
@Post('upload')
@UseInterceptors(AmazonS3FileInterceptor('avatar', {
dynamicPath: 'profile',
randomFilename: true,
}))
async uploadFile(@Body() params, @UploadedFile() file): Promise<string> {
params.avatar = file.location;
return await this.service.upload(params);
}
Could you please show me the entire code from a app.module.ts
file?
@Module({
imports: [
ConfigModule,
ConfigModule.load(
path.resolve(__dirname, 'config', '**', '!(*.d).{ts,js}'),
{
path: path.resolve(process.cwd(), 'env', !ENV ? '.env' : `.env.${ENV}`),
},
),
TypeOrmModule.forRootAsync({
useFactory: (config: ConfigService) => config.get('database'),
inject: [ConfigService],
}),
MulterExtendedModule.registerAsync({
useFactory: (config: ConfigService) => config.get('s3'),
inject: [ConfigService],
}),
PassportModule.register({ defaultStrategy: 'jwt' }),
JwtModule.register(JWT_MODULE_OPTIONS),
CacheModule.registerAsync({
imports: [ConfigModule],
useFactory: async (config: ConfigService) => config.get('cache'),
inject: [ConfigService],
}),
HttpModule,
...
],
})
export class AppModule { }
You should import the MulterExtendedModule
on the same level where the controller wants to use it. (Solved it from VS Live Share)
thank you @jeffminsungkim , you were very kind & helpful
Sorry, I was unable to resolve the issue. Can you please explain what is meant by importing MulterExtendedModule
on the same level where the controller is?
Many thanks for the package and all your work!
Sorry, I was unable to resolve the issue. Can you please explain what is meant by importing
MulterExtendedModule
on the same level where the controller is? Many thanks for the package and all your work!
Were you able to fix this issue.?
thank you @jeffminsungkim , you were very kind & helpful
Hey mate, How did he fix it.?
Did I miss anything?