feat: Migrate file storage to unified data directory

This commit is contained in:
Maksim Eltyshev
2026-01-31 20:27:15 +01:00
parent 6335b3bd3c
commit 052edc9fb1
17 changed files with 89 additions and 151 deletions
+5 -5
View File
@@ -8,6 +8,7 @@
* https://sailsjs.com/config/custom
*/
const path = require('path');
const { URL } = require('url');
const bytes = require('bytes');
const sails = require('sails');
@@ -48,12 +49,11 @@ module.exports.custom = {
// Location to receive uploaded files in. Default (non-string value) is a Sails-specific location.
uploadsTempPath: null,
uploadsBasePath: sails.config.appPath,
uploadsBasePath: path.join(sails.config.appPath, 'data'),
preloadedFaviconsPathSegment: 'public/preloaded-favicons',
faviconsPathSegment: 'public/favicons',
userAvatarsPathSegment: 'public/user-avatars',
backgroundImagesPathSegment: 'public/background-images',
faviconsPathSegment: 'protected/favicons',
userAvatarsPathSegment: 'protected/user-avatars',
backgroundImagesPathSegment: 'protected/background-images',
attachmentsPathSegment: 'private/attachments',
defaultAdminEmail:
+2 -10
View File
@@ -80,13 +80,13 @@ const serveStatic = async (prefix, getPathSegment, req, res) => {
return readStream.pipe(res);
};
const publicStaticDirServer = (prefix, getPathSegment) => (req, res, next) => {
/* const publicStaticDirServer = (prefix, getPathSegment) => (req, res, next) => {
if (!req.url.startsWith(prefix)) {
return next();
}
return serveStatic(prefix, getPathSegment, req, res);
};
}; */
const protectedStaticDirServer = (prefix, getPathSegment) => (req, res, next) => {
if (!req.url.startsWith(prefix)) {
@@ -235,14 +235,6 @@ module.exports.routes = {
'PATCH /api/_internal/config': '_internal/update-config',
'GET /preloaded-favicons/*': {
fn: publicStaticDirServer(
'/preloaded-favicons',
() => sails.config.custom.preloadedFaviconsPathSegment,
),
skipAssets: false,
},
'GET /favicons/*': {
fn: protectedStaticDirServer('/favicons', () => sails.config.custom.faviconsPathSegment),
skipAssets: false,