Property 'location' does not exist on type 'File'
NikhilMandaliya opened this issue · 2 comments
NikhilMandaliya commented
public create = async (req: Request, res: Response) => {
req.body.profileImage = req.file?.location;
req.body.user = req.tokenData.user;
const responseData = await this.userRepository.createUser(req.body as CreateUserInterface);
return generalResponse(req, res, responseData, successMessage.USER_CREATE_SUCCESS, false, responseFlag.SUCCESS);
};
This code block, throws this TS error
TSError: ⨯ Unable to compile TypeScript:
src/controllers/user/user.controller.ts:24:39 - error TS2339: Property 'location' does not exist on type 'File'.
24 req.body.profileImage = req.file?.location;
Log of req.file if working fine
req.file: {
fieldname: 'profileImage',
originalname: 'profile.jpeg',
encoding: '7bit',
mimetype: 'image/jpeg',
size: 6182,
bucket: 'aws-bucket-name',
key: '1711716164482-profile.jpeg',
acl: 'private',
contentType: 'application/octet-stream',
contentDisposition: null,
contentEncoding: null,
storageClass: 'STANDARD',
serverSideEncryption: null,
metadata: { fieldName: 'profileImage' },
location: 'http://localhost:4566/aws-bucket-name/1711716164482-profile.jpeg',
etag: '"806170f0b2a191c8c967372af939cc6d"',
versionId: undefined
}
NikhilMandaliya commented
const file = req.file as Express.MulterS3.File;
const profileImage = file?.key;
This works
But type of req.file if Express.Request.file?: Express.Multer.File | undefined
Shouldn't it be Express.Request.file?: Express.MulterS3.File | undefined
??
C-Collamar commented