S3 gallery

This commit is contained in:
2026-06-19 12:35:49 +03:30
parent 85c8107799
commit c73027540a
3 changed files with 276 additions and 206 deletions
+10 -3
View File
@@ -1,16 +1,23 @@
const mongoose = require('mongoose');
const mongoosePaginate = require('mongoose-paginate-v2');
const s3Storage = require('../plugins/s3Storage');
function galleryUrl(img, prefix) {
if (!img) return null;
if (img.startsWith('http://') || img.startsWith('https://')) return img;
return s3Storage.getPublicUrl(`${prefix}/${img}`);
}
function image(img) {
if (img) return '/uploads/images/gallery/' + img
return galleryUrl(img, 'uploads/images/gallery');
}
function graphic(img) {
if (img) return '/uploads/graphics/gallery/' + img
return galleryUrl(img, 'uploads/graphics/gallery');
}
function video(vdo) {
if (vdo) return '/uploads/videos/gallery/' + vdo
return galleryUrl(vdo, 'uploads/videos/gallery');
}
const GallerySchema = mongoose.Schema({