mirror of
https://github.com/Mintplex-Labs/anything-llm.git
synced 2024-11-09 00:10:10 +01:00
fcb591d364
* fix sizing of onboarding modals & lint * fix extra scrolling on mobile onboarding flow * added message to use desktop for onboarding * linting * add arrow to scroll to bottom (debounced) and fix chat scrolling to always scroll to very bottom on message history change * fix for empty chat * change mobile alert copy * WIP adding PFP upload support * WIP pfp for users * edit account menu complete with change username/password and upload profile picture * add pfp context to update all instances of usePfp hook on update * linting * add context for logo change to immediately update logo * fix div with bullet points to use list-disc instead * fix: small changes * update multer file storage locations * fix: use STORAGE_DIR for filepathing --------- Co-authored-by: timothycarambat <rambat1010@gmail.com>
85 lines
2.4 KiB
JavaScript
85 lines
2.4 KiB
JavaScript
const multer = require("multer");
|
|
const path = require("path");
|
|
const fs = require("fs");
|
|
const { v4 } = require("uuid");
|
|
|
|
function setupMulter() {
|
|
// Handle File uploads for auto-uploading.
|
|
const storage = multer.diskStorage({
|
|
destination: function (_, _, cb) {
|
|
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);
|
|
},
|
|
});
|
|
|
|
return { handleUploads: multer({ storage }) };
|
|
}
|
|
|
|
function setupDataImports() {
|
|
// Handle File uploads for auto-uploading.
|
|
const storage = multer.diskStorage({
|
|
destination: function (_, _, cb) {
|
|
const uploadOutput = path.resolve(__dirname, `../../storage/imports`);
|
|
fs.mkdirSync(uploadOutput, { recursive: true });
|
|
return cb(null, uploadOutput);
|
|
},
|
|
filename: function (_, file, cb) {
|
|
cb(null, file.originalname);
|
|
},
|
|
});
|
|
|
|
return { handleImports: multer({ storage }) };
|
|
}
|
|
|
|
function setupLogoUploads() {
|
|
// Handle Logo uploads.
|
|
const storage = multer.diskStorage({
|
|
destination: function (_, _, cb) {
|
|
const uploadOutput =
|
|
process.env.NODE_ENV === "development"
|
|
? path.resolve(__dirname, `../../storage/assets`)
|
|
: path.resolve(process.env.STORAGE_DIR, "assets");
|
|
fs.mkdirSync(uploadOutput, { recursive: true });
|
|
return cb(null, uploadOutput);
|
|
},
|
|
filename: function (_, file, cb) {
|
|
cb(null, file.originalname);
|
|
},
|
|
});
|
|
|
|
return { handleLogoUploads: multer({ storage }) };
|
|
}
|
|
|
|
function setupPfpUploads() {
|
|
const storage = multer.diskStorage({
|
|
destination: function (_, _, cb) {
|
|
const uploadOutput =
|
|
process.env.NODE_ENV === "development"
|
|
? path.resolve(__dirname, `../../storage/assets/pfp`)
|
|
: path.resolve(process.env.STORAGE_DIR, "assets/pfp");
|
|
fs.mkdirSync(uploadOutput, { recursive: true });
|
|
return cb(null, uploadOutput);
|
|
},
|
|
filename: function (req, file, cb) {
|
|
const randomFileName = `${v4()}${path.extname(file.originalname)}`;
|
|
req.randomFileName = randomFileName;
|
|
cb(null, randomFileName);
|
|
},
|
|
});
|
|
|
|
return { handlePfpUploads: multer({ storage }) };
|
|
}
|
|
|
|
module.exports = {
|
|
setupMulter,
|
|
setupDataImports,
|
|
setupLogoUploads,
|
|
setupPfpUploads,
|
|
};
|