Skip to content

Commit f2d08b2

Browse files
committed
10 Aug 2023, 14:19
1 parent bdac4cf commit f2d08b2

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/controllers/product/productController.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,12 @@ const remove = async (req: Request, res: Response, next: NextFunction) => {
191191

192192
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
193193
//[+]2. Get the path of the image file stored in the db ( before getter are invoked and the dynamic APP_URL is attached)
194-
const filePath = product._doc.image;
194+
195+
const filePath = `${APP_ROOT}/${product._doc.image}`;
196+
195197
console.log(filePath);
196-
fs.unlink(`${APP_ROOT}/${filePath}`, (err) => {
198+
199+
fs.unlink(filePath, (err) => {
197200
if (err) {
198201
return next(CustomErrorHandler.multerError('❌ Could not delete file'));
199202
} else console.log('✅ Uploaded file deleted');

0 commit comments

Comments
 (0)