ADD: API_URL to env

ADD: DocumentUrls and mainImageUrls field in belonging model
FIX: Indexing bugs for belonging
ADD: getImage endpoint to get private images
ADD: PrivateUrl field as virtual
FIX: Minor bug in bucketDeleteFile service
ADD: Word type to multer file checker
This commit is contained in:
2025-04-27 16:17:17 +03:30
parent d7d2d98b6d
commit 4fc323cd16
8 changed files with 100 additions and 29 deletions
+23 -1
View File
@@ -7,6 +7,7 @@ exports.bucketSingleUpload = catchAsync(async (req, res, next) => {
res.status(200).json({
status: 'success',
data: fileData,
bucketName: req.params.bucketName,
})
})
@@ -27,6 +28,7 @@ exports.bucketMultiUpload = catchAsync(async (req, res, next) => {
status: 'success',
results: files.length,
data: files,
bucketName: req.params.bucketName,
})
})
@@ -49,11 +51,31 @@ exports.getSignedUrl = catchAsync(async (req, res, next) => {
})
})
exports.getImage = catchAsync(async (req, res, next) => {
const { bucketName, fileName } = req.params;
const imageData = await fileService.getImage(bucketName, fileName);
if (!imageData) {
return res.status(404).json({
status: 'fail',
message: 'Image not found'
});
}
// Set appropriate headers for the image response
res.set('Content-Type', imageData.contentType);
res.send(imageData.buffer);
});
exports.bucketDeleteFile = catchAsync(async (req, res, next) => {
await fileService.bucketDeleteFile(req.body, req.params.bucketName)
const { fileName } = await fileService.bucketDeleteFile(req.body, req.params.bucketName)
res.status(200).json({
status: 'success',
data: fileName,
})
})