feat: Migrate file storage to unified data directory
This commit is contained in:
@@ -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
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user