updates for contacts & tenders Modules
This commit is contained in:
@@ -227,6 +227,39 @@ export class TendersController {
|
||||
next(error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
async viewAttachment(req: AuthRequest, res: Response, next: NextFunction) {
|
||||
try {
|
||||
const file = await tendersService.getAttachmentFile(req.params.attachmentId)
|
||||
|
||||
const fs = require('fs')
|
||||
if (!fs.existsSync(file)) {
|
||||
return res.status(404).json(
|
||||
ResponseFormatter.error('File not found', 'الملف غير موجود')
|
||||
)
|
||||
}
|
||||
|
||||
const path = require('path')
|
||||
return res.sendFile(path.resolve(file))
|
||||
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
next(error)
|
||||
}
|
||||
}
|
||||
|
||||
async deleteAttachment(req: AuthRequest, res: Response, next: NextFunction) {
|
||||
try {
|
||||
await tendersService.deleteAttachment(req.params.attachmentId)
|
||||
res.json(ResponseFormatter.success(null, 'Deleted'))
|
||||
} catch (error) {
|
||||
next(error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export const tendersController = new TendersController();
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user