Fixe Image Upload #1
All checks were successful
Neutral/pipeline/head This commit looks good

This commit is contained in:
CICD - Pipeline 2023-03-23 19:08:38 +01:00
parent 7877729100
commit 493b6973c5
5 changed files with 7 additions and 12 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "neutral", "name": "neutral",
"version": "DEV_5.0", "version": "DEV_5",
"private": true, "private": true,
"nodemonConfig": { "nodemonConfig": {
"ext": "js, html", "ext": "js, html",

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 71 KiB

View File

@ -38,8 +38,6 @@ router.post("/", function(req, res, next) {
const image = req.files.apic const image = req.files.apic
console.log("test")
if(req.headers.uploadforuser != null) { if(req.headers.uploadforuser != null) {
if(check.permLevel == 4) { if(check.permLevel == 4) {
@ -49,6 +47,7 @@ router.post("/", function(req, res, next) {
var uploadPath = ""; var uploadPath = "";
var uploadDir = __dirname.replace("routes","public" + path.sep + "images" + path.sep + "userspics" + path.sep) var uploadDir = __dirname.replace("routes","public" + path.sep + "images" + path.sep + "userspics" + path.sep)
if(req.files.apic.mimetype == "image/png") { if(req.files.apic.mimetype == "image/png") {
uploadPath = req.headers.uploadforuser + ".png" uploadPath = req.headers.uploadforuser + ".png"
@ -59,7 +58,7 @@ router.post("/", function(req, res, next) {
uploadPath = req.headers.uploadforuser+ ".jpg" uploadPath = req.headers.uploadforuser+ ".jpg"
} }
image.mv(uploadPath, function(err) { image.mv(__dirname + path.sep + uploadPath, function(err) {
if(err) { if(err) {
res.send({"result":"success", "content": "La photo de profil n'a pas pu être chargé."}) res.send({"result":"success", "content": "La photo de profil n'a pas pu être chargé."})
console.log(err) console.log(err)
@ -176,7 +175,7 @@ router.post("/", function(req, res, next) {
uploadPath = ntr.checkToken(req, res).name + ".jpg" uploadPath = ntr.checkToken(req, res).name + ".jpg"
} }
image.mv(uploadPath, function(err) { image.mv(__dirname + path.sep + uploadPath, function(err) {
if(err) { if(err) {
res.send({"result":"success", "content": "La photo de profil n'a pas pu être chargé."}) res.send({"result":"success", "content": "La photo de profil n'a pas pu être chargé."})
console.log(err) console.log(err)

View File

@ -9,5 +9,5 @@
"livableToken": true, "livableToken": true,
"createdAt": 1679260759114 "createdAt": 1679260759114
}, },
"lastconnexion": 1679594165151 "lastconnexion": 1679594782961
} }

View File

@ -4,10 +4,6 @@
"uuid": "c8f353a4-d0df-4c10-bccc-d4f47daf0f51", "uuid": "c8f353a4-d0df-4c10-bccc-d4f47daf0f51",
"fullname": "Administrateur", "fullname": "Administrateur",
"permissionLevel": 4, "permissionLevel": 4,
"token": { "token": {},
"tokenID": "c750c10a-f69d-4dd2-8a35-65d8a74897bb",
"livableToken": false,
"createdAt": 1677339320398
},
"lastconnexion": 1677339336836 "lastconnexion": 1677339336836
} }