S3 : news controller

This commit is contained in:
2026-06-19 12:26:40 +03:30
parent 99a9f9ace5
commit 85c8107799
3 changed files with 114 additions and 152 deletions
+5 -3
View File
@@ -8,12 +8,14 @@ function image(img) {
return s3Storage.getPublicUrl(`uploads/images/news/${img}`);
}
function file(file) {
return '/uploads/files/newsAttachments/' + file
function attachmentFile(file) {
if (!file) return null;
if (file.startsWith('http://') || file.startsWith('https://')) return file;
return s3Storage.getPublicUrl(`uploads/files/newsAttachments/${file}`);
}
const NewsAttachmentSchema = mongoose.Schema({
file: {type: String, get: file},
file: {type: String, get: attachmentFile},
title: String
})