mirror of
https://github.com/Mintplex-Labs/anything-llm.git
synced 2024-11-04 14:00:11 +01:00
26 lines
681 B
JavaScript
26 lines
681 B
JavaScript
|
function setupMulter() {
|
||
|
const multer = require("multer");
|
||
|
// Handle File uploads for auto-uploading.
|
||
|
const storage = multer.diskStorage({
|
||
|
destination: function (_, _, cb) {
|
||
|
const path = require("path");
|
||
|
const uploadOutput =
|
||
|
process.env.NODE_ENV === "development"
|
||
|
? path.resolve(__dirname, `../../../collector/hotdir`)
|
||
|
: path.resolve(process.env.STORAGE_DIR, `../../collector/hotdir`);
|
||
|
cb(null, uploadOutput);
|
||
|
},
|
||
|
filename: function (_, file, cb) {
|
||
|
cb(null, file.originalname);
|
||
|
},
|
||
|
});
|
||
|
const upload = multer({
|
||
|
storage,
|
||
|
});
|
||
|
return { handleUploads: upload };
|
||
|
}
|
||
|
|
||
|
module.exports = {
|
||
|
setupMulter,
|
||
|
};
|