mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-22 19:30:15 +01:00
refactor: Update multer storage destination to use promise-based getAppConfig and improve error handling in tests
This commit is contained in:
parent
5bb731764c
commit
eeab69ff7f
2 changed files with 19 additions and 18 deletions
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue