diff --git a/packages/azure_file_storage/README.md b/packages/azure_file_storage/README.md index 2e0f42922..598d78a93 100644 --- a/packages/azure_file_storage/README.md +++ b/packages/azure_file_storage/README.md @@ -50,7 +50,10 @@ Edit the `config/default.json` file in the root directory of your EverShop insta ```json { ..., - "file_storage": "azure" + "system": { + ..., + "file_storage": "azure" + } } ``` diff --git a/packages/azure_file_storage/api/fileBrowser/azureFileBrowser.js b/packages/azure_file_storage/api/fileBrowser/azureFileBrowser.js index 9cfb08937..22c39d7a3 100644 --- a/packages/azure_file_storage/api/fileBrowser/azureFileBrowser.js +++ b/packages/azure_file_storage/api/fileBrowser/azureFileBrowser.js @@ -9,7 +9,7 @@ const { let blobServiceClient; let containerName; -if (getConfig('file_storage') === 'azure') { +if (getConfig('system.file_storage') === 'azure') { blobServiceClient = BlobServiceClient.fromConnectionString( getEnv('AZURE_STORAGE_CONNECTION_STRING') ); @@ -18,7 +18,7 @@ if (getConfig('file_storage') === 'azure') { module.exports = async (request, response, delegate, next) => { // If the file storage is not Azure, call the next middleware function - if (getConfig('file_storage') !== 'azure') { + if (getConfig('system.file_storage') !== 'azure') { next(); } else { try { diff --git a/packages/azure_file_storage/api/fileDelete/azureFileDelete.js b/packages/azure_file_storage/api/fileDelete/azureFileDelete.js index d2b85af02..34b73f28e 100644 --- a/packages/azure_file_storage/api/fileDelete/azureFileDelete.js +++ b/packages/azure_file_storage/api/fileDelete/azureFileDelete.js @@ -10,7 +10,7 @@ const { let blobServiceClient; let containerName; -if (getConfig('file_storage') === 'azure') { +if (getConfig('system.file_storage') === 'azure') { blobServiceClient = BlobServiceClient.fromConnectionString( getEnv('AZURE_STORAGE_CONNECTION_STRING') ); @@ -18,7 +18,7 @@ if (getConfig('file_storage') === 'azure') { } module.exports = async (request, response, delegate, next) => { - if (getConfig('file_storage') !== 'azure') { + if (getConfig('system.file_storage') !== 'azure') { next(); } else { try { diff --git a/packages/azure_file_storage/api/folderCreate/azureFolderCreate.js b/packages/azure_file_storage/api/folderCreate/azureFolderCreate.js index 9fa258a22..23f7a1d72 100644 --- a/packages/azure_file_storage/api/folderCreate/azureFolderCreate.js +++ b/packages/azure_file_storage/api/folderCreate/azureFolderCreate.js @@ -10,7 +10,7 @@ const { let blobServiceClient; let containerName; -if (getConfig('file_storage') === 'azure') { +if (getConfig('system.file_storage') === 'azure') { blobServiceClient = BlobServiceClient.fromConnectionString( getEnv('AZURE_STORAGE_CONNECTION_STRING') ); @@ -19,7 +19,7 @@ if (getConfig('file_storage') === 'azure') { module.exports = async (request, response, delegate, next) => { // If the file storage is not Azure, call the next middleware function - if (getConfig('file_storage') !== 'azure') { + if (getConfig('system.file_storage') !== 'azure') { next(); } else { try { diff --git a/packages/evershop/src/modules/catalog/subscribers/product_image_added/localGenerateProductImageVariant.js b/packages/evershop/src/modules/catalog/subscribers/product_image_added/localGenerateProductImageVariant.js index f395dc74f..a5b8c3df6 100644 --- a/packages/evershop/src/modules/catalog/subscribers/product_image_added/localGenerateProductImageVariant.js +++ b/packages/evershop/src/modules/catalog/subscribers/product_image_added/localGenerateProductImageVariant.js @@ -8,7 +8,7 @@ const { CONSTANTS } = require('@evershop/evershop/src/lib/helpers'); const { debug } = require('@evershop/evershop/src/lib/log/debuger'); module.exports = async function localGenerateProductImageVariant(data) { - if (getConfig('file_storage') === 'local') { + if (getConfig('system.file_storage') === 'local') { try { const imagePath = data.origin_image.replace('/assets', ''); const mediaPath = path.join(CONSTANTS.MEDIAPATH, imagePath); diff --git a/packages/evershop/src/modules/cms/api/fileBrowser/browser.js b/packages/evershop/src/modules/cms/api/fileBrowser/browser.js index b81f2fcfc..a4d630676 100644 --- a/packages/evershop/src/modules/cms/api/fileBrowser/browser.js +++ b/packages/evershop/src/modules/cms/api/fileBrowser/browser.js @@ -10,7 +10,7 @@ const { getConfig } = require('@evershop/evershop/src/lib/util/getConfig'); // eslint-disable-next-line no-unused-vars module.exports = (request, response, delegate, next) => { - if (getConfig('file_storage') !== 'local') { + if (getConfig('system.file_storage') !== 'local') { next(); } else { const path = request.params[0] || ''; diff --git a/packages/evershop/src/modules/cms/api/fileDelete/deleteFile.js b/packages/evershop/src/modules/cms/api/fileDelete/deleteFile.js index 5c55562d1..58f7c3cd9 100644 --- a/packages/evershop/src/modules/cms/api/fileDelete/deleteFile.js +++ b/packages/evershop/src/modules/cms/api/fileDelete/deleteFile.js @@ -9,7 +9,7 @@ const { getConfig } = require('@evershop/evershop/src/lib/util/getConfig'); // eslint-disable-next-line no-unused-vars module.exports = (request, response, delegate, next) => { - if (getConfig('file_storage') !== 'local') { + if (getConfig('system.file_storage') !== 'local') { next(); } else { const path = request.params[0] || ''; diff --git a/packages/evershop/src/modules/cms/api/folderCreate/createFolder.js b/packages/evershop/src/modules/cms/api/folderCreate/createFolder.js index 9c704e963..5b5d624d0 100644 --- a/packages/evershop/src/modules/cms/api/folderCreate/createFolder.js +++ b/packages/evershop/src/modules/cms/api/folderCreate/createFolder.js @@ -9,7 +9,7 @@ const { getConfig } = require('@evershop/evershop/src/lib/util/getConfig'); // eslint-disable-next-line no-unused-vars module.exports = (request, response, delegate, next) => { - if (getConfig('file_storage') !== 'local') { + if (getConfig('system.file_storage') !== 'local') { next(); } else { const { path } = request.body || ''; diff --git a/packages/evershop/src/modules/cms/api/imageUpload/[multerFile]upload.js b/packages/evershop/src/modules/cms/api/imageUpload/[multerFile]upload.js index 872fd462d..fe0a59ce2 100644 --- a/packages/evershop/src/modules/cms/api/imageUpload/[multerFile]upload.js +++ b/packages/evershop/src/modules/cms/api/imageUpload/[multerFile]upload.js @@ -9,7 +9,7 @@ const { getConfig } = require('@evershop/evershop/src/lib/util/getConfig'); // eslint-disable-next-line no-unused-vars module.exports = (request, response, delegate, next) => { - if (getConfig('file_storage') !== 'local') { + if (getConfig('system.file_storage') !== 'local') { next(); } else if (!request.files || request.files.length === 0) { response.status(INVALID_PAYLOAD).json({ diff --git a/packages/evershop/src/modules/cms/bootstrap.js b/packages/evershop/src/modules/cms/bootstrap.js index 53cd55ab2..ae9c0a4d2 100644 --- a/packages/evershop/src/modules/cms/bootstrap.js +++ b/packages/evershop/src/modules/cms/bootstrap.js @@ -17,4 +17,7 @@ module.exports = () => { copyRight: `© 2022 Evershop. All Rights Reserved.` }; config.util.setModuleDefaults('themeConfig', themeConfig); + config.util.setModuleDefaults('system', { + file_storage: 'local' + }); }; diff --git a/packages/evershop/src/modules/cms/services/getMulter.js b/packages/evershop/src/modules/cms/services/getMulter.js index 51006d90c..8e325ae2d 100644 --- a/packages/evershop/src/modules/cms/services/getMulter.js +++ b/packages/evershop/src/modules/cms/services/getMulter.js @@ -44,8 +44,7 @@ const diskStorage = multer.diskStorage({ }); module.exports.getMulter = () => { - const storageProvider = getConfig('file_storage', 'local'); - + const storageProvider = getConfig('system.file_storage', 'local'); if (storageProvider === 'local') { return multer({ storage: diskStorage, fileFilter }); } else { diff --git a/packages/s3_file_storage/README.md b/packages/s3_file_storage/README.md index 3e3b6e702..133992a2d 100644 --- a/packages/s3_file_storage/README.md +++ b/packages/s3_file_storage/README.md @@ -52,7 +52,10 @@ Edit the `config/default.json` file in the root directory of your EverShop insta ```json { ..., - "file_storage": "s3" + "system": { + ..., + "file_storage": "s3" + } } ``` diff --git a/packages/s3_file_storage/api/folderCreate/awsFolderCreate.js b/packages/s3_file_storage/api/folderCreate/awsFolderCreate.js index c8881f33b..2a11e7c74 100644 --- a/packages/s3_file_storage/api/folderCreate/awsFolderCreate.js +++ b/packages/s3_file_storage/api/folderCreate/awsFolderCreate.js @@ -14,7 +14,7 @@ const bucketName = getEnv('AWS_BUCKET_NAME'); module.exports = async (request, response, delegate, next) => { // If the file storage is not S3, call the next middleware function - if (getConfig('file_storage') !== 's3') { + if (getConfig('system.file_storage') !== 's3') { next(); } else { try {