S3 : news controller
This commit is contained in:
@@ -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
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user