Setup KHUFU_UPLOAD_PATH
This commit is contained in:
parent
7c5a6dd326
commit
2cf99f5577
5 changed files with 21 additions and 9 deletions
11
dist/predeploy-vanilla.sh
vendored
11
dist/predeploy-vanilla.sh
vendored
|
@ -4,8 +4,15 @@ echo "Creating vanilla predeploy!"
|
||||||
if [[ $PWD == *"dist" ]];
|
if [[ $PWD == *"dist" ]];
|
||||||
then cd ..
|
then cd ..
|
||||||
fi
|
fi
|
||||||
|
# If .env exists, ignore it
|
||||||
|
if [[ ! -f ".env" ]];then
|
||||||
|
echo "Building vanilla env file!"
|
||||||
|
echo "KHUFU_UPLOAD_PATH=/srv/uploads">> .env
|
||||||
|
fi
|
||||||
# Install node dependencies
|
# Install node dependencies
|
||||||
echo "Installing node depencencies!"
|
echo "Installing node depencencies!"
|
||||||
npm i
|
npm i
|
||||||
echo "Building Docker Image!"
|
echo "Building JS Bundle!"
|
||||||
npm run build:all
|
npm run build:react
|
||||||
|
echo "Building docker image"
|
||||||
|
docker-compose build
|
||||||
|
|
|
@ -9,6 +9,8 @@ services:
|
||||||
- ALEXANDRIA_INTERNAL_URL=${ALEXANDRIA_INTERNAL_URL}
|
- ALEXANDRIA_INTERNAL_URL=${ALEXANDRIA_INTERNAL_URL}
|
||||||
- ALEXANDRIA_DATABASE_PASSWORD=${ALEXANDRIA_DATABASE_PASSWORD}
|
- ALEXANDRIA_DATABASE_PASSWORD=${ALEXANDRIA_DATABASE_PASSWORD}
|
||||||
- CAIRO_PUBLIC_URL=${CAIRO_PUBLIC_URL}
|
- CAIRO_PUBLIC_URL=${CAIRO_PUBLIC_URL}
|
||||||
|
env_file:
|
||||||
|
- .env
|
||||||
networks:
|
networks:
|
||||||
- dunestorm_dev
|
- dunestorm_dev
|
||||||
networks:
|
networks:
|
||||||
|
|
|
@ -40,7 +40,8 @@
|
||||||
"ext": "js,json",
|
"ext": "js,json",
|
||||||
"signal": "SIGINT",
|
"signal": "SIGINT",
|
||||||
"env": {
|
"env": {
|
||||||
"CAIRO_URL": "http://localhost:52000"
|
"CAIRO_URL": "http://localhost:52000",
|
||||||
|
"KHUFU_UPLOAD_PATH": "uploads/"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,12 +6,15 @@ const multer = require("multer");
|
||||||
const config = require("../config.json");
|
const config = require("../config.json");
|
||||||
//Multer Configs
|
//Multer Configs
|
||||||
const userUploadStorage = multer.diskStorage({
|
const userUploadStorage = multer.diskStorage({
|
||||||
destination: (req, file, cb) => cb(null, userUploadDestination(req.user.cairoId)),
|
destination: (req, file, cb) =>
|
||||||
|
cb(null, userUploadDestination(req.user.cairoId)),
|
||||||
filename: (req, file, cb) => {
|
filename: (req, file, cb) => {
|
||||||
const n = file.originalname.replaceAll(" ", "_");
|
const n = file.originalname.replaceAll(" ", "_");
|
||||||
const fileName = `${Date.now()}-${n}`;
|
const fileName = `${Date.now()}-${n}`;
|
||||||
req.on("aborted", () =>
|
req.on("aborted", () =>
|
||||||
cancelUpload(resolvePath(userUploadDestination(req.user.cairoId), fileName))
|
cancelUpload(
|
||||||
|
resolvePath(userUploadDestination(req.user.cairoId), fileName)
|
||||||
|
)
|
||||||
);
|
);
|
||||||
cb(null, fileName);
|
cb(null, fileName);
|
||||||
},
|
},
|
||||||
|
@ -22,9 +25,9 @@ const userUpload = multer({
|
||||||
|
|
||||||
//Helper Methods
|
//Helper Methods
|
||||||
function userUploadDestination(user_id) {
|
function userUploadDestination(user_id) {
|
||||||
if (!fs.existsSync(resolvePath(config.Storage.UploadPath)))
|
if (!fs.existsSync(resolvePath(process.env.KHUFU_UPLOAD_PATH)))
|
||||||
fs.mkdirSync(resolvePath(config.Storage.UploadPath));
|
fs.mkdirSync(resolvePath(process.env.KHUFU_UPLOAD_PATH));
|
||||||
const destination = resolvePath(config.Storage.UploadPath, `${user_id}`);
|
const destination = resolvePath(process.env.KHUFU_UPLOAD_PATH, `${user_id}`);
|
||||||
if (!fs.existsSync(destination)) fs.mkdirSync(destination);
|
if (!fs.existsSync(destination)) fs.mkdirSync(destination);
|
||||||
return destination;
|
return destination;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
{
|
{
|
||||||
"Storage": {
|
"Storage": {
|
||||||
"UploadPath": "src/uploads/",
|
|
||||||
"UserStorageSize": 25,
|
"UserStorageSize": 25,
|
||||||
"UserStorageUnit": 1048576,
|
"UserStorageUnit": 1048576,
|
||||||
"UploadMaxSize": ""
|
"UploadMaxSize": ""
|
||||||
|
|
Reference in a new issue