refactor: Update multer storage destination to use promise-based getAppConfig and improve error handling in tests

This commit is contained in:
Danny Avila 2025-08-17 17:36:58 -04:00
parent 5bb731764c
commit eeab69ff7f
No known key found for this signature in database
GPG key ID: BF31EEB2C5CA0956
2 changed files with 19 additions and 18 deletions

View file

@ -7,13 +7,18 @@ const { fileConfig: defaultFileConfig, mergeFileConfig } = require('librechat-da
const { getCustomConfig, getAppConfig } = require('~/server/services/Config');
const storage = multer.diskStorage({
destination: async function (req, file, cb) {
const appConfig = await getAppConfig({ role: req.user?.role });
const outputPath = path.join(appConfig.paths.uploads, 'temp', req.user.id);
if (!fs.existsSync(outputPath)) {
fs.mkdirSync(outputPath, { recursive: true });
}
cb(null, outputPath);
destination: function (req, file, cb) {
getAppConfig({ role: req.user?.role })
.then((appConfig) => {
const outputPath = path.join(appConfig.paths.uploads, 'temp', req.user.id);
if (!fs.existsSync(outputPath)) {
fs.mkdirSync(outputPath, { recursive: true });
}
cb(null, outputPath);
})
.catch((error) => {
cb(error);
});
},
filename: function (req, file, cb) {
req.file_id = crypto.randomUUID();