Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Property 'location' does not exist on type 'File' #214

Open
NikhilMandaliya opened this issue Mar 29, 2024 · 1 comment
Open

Property 'location' does not exist on type 'File' #214

NikhilMandaliya opened this issue Mar 29, 2024 · 1 comment

Comments

@NikhilMandaliya
Copy link

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
Copy link
Author

NikhilMandaliya commented Mar 29, 2024

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??

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant