jeffminsungkim / nestjs-multer-extended

💪 Extended MulterModule for NestJS with flexible S3 upload and helpful features
MIT License
203 stars 47 forks source link

[ExceptionsHandler] Cannot read property 'storageOpts' of undefined #182

Closed klalex closed 4 years ago

klalex commented 4 years ago

I did follow all instructions from README and getting this exception:

[Nest] 66802 - 07/09/2020, 12:28:56 PM [ExceptionsHandler] Cannot read property 'storageOpts' of undefined +10269ms TypeError: Cannot read property 'storageOpts' of undefined at MixinInterceptor.pickStorageOptions (/Users/alex/Projects/AlumniAces-Backend/node_modules/nestjs-multer-extended/dist/interceptors/amazon-s3-file.interceptor.js:69:112) at MixinInterceptor. (/Users/alex/Projects/AlumniAces-Backend/node_modules/nestjs-multer-extended/dist/interceptors/amazon-s3-file.interceptor.js:43:48) at Generator.next () at /Users/alex/Projects/AlumniAces-Backend/node_modules/nestjs-multer-extended/dist/interceptors/amazon-s3-file.interceptor.js:20:71 at new Promise () at __awaiter (/Users/alex/Projects/AlumniAces-Backend/node_modules/nestjs-multer-extended/dist/interceptors/amazon-s3-file.interceptor.js:16:12) at MixinInterceptor.intercept (/Users/alex/Projects/AlumniAces-Backend/node_modules/nestjs-multer-extended/dist/interceptors/amazon-s3-file.interceptor.js:40:20) at /Users/alex/Projects/AlumniAces-Backend/node_modules/@nestjs/core/interceptors/interceptors-consumer.js:22:36 at InterceptorsConsumer.intercept (/Users/alex/Projects/AlumniAces-Backend/node_modules/@nestjs/core/interceptors/interceptors-consumer.js:24:24) at /Users/alex/Projects/AlumniAces-Backend/node_modules/@nestjs/core/router/router-execution-context.js:45:60

I use this controller action:

@UseInterceptors(
        AmazonS3FileInterceptor('file', {
            randomFilename: true
        }),
    )
    uploadFile(@UploadedFile() file) {
        console.log(file);
    }

If I remove randomFilename option it just prints out file object but doesn't upload to S3.

Also I see it uses correct S3 settings:

[Nest] 66802 - 07/09/2020, 12:28:29 PM [MulterConfigLoader] {"accessKeyId":"*","secretAccessKey":"*****","region":"us-east-1","bucket":"***","basePath":""}

Anything I did wrong?

jeffminsungkim commented 4 years ago

We've already gone through this issue. Please checkout #171 Thank you 😃

Just an FYI, this issue does not belong to this module. You should follow the correct Nest(Angular) import principle.