From 7b07addaf59936278c767d900aabca6924185d32 Mon Sep 17 00:00:00 2001 From: "k.triantafyllou" Date: Thu, 27 Jun 2019 13:44:54 +0000 Subject: [PATCH] [UploadService]: Check if a url is already tiny. git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-portal/trunk@56240 d315682c-612b-4755-9ff5-7f18f6832af3 --- services/upload/properties.file | 2 +- services/upload/uploadService.js | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/services/upload/properties.file b/services/upload/properties.file index d4709831..f124b164 100644 --- a/services/upload/properties.file +++ b/services/upload/properties.file @@ -2,4 +2,4 @@ userInfoUrl = http://scoobydoo.di.uoa.gr:8080/dnet-openaire-users-1.0.0-SNAPSHOT originServer = .di.uoa.gr post.allowed = /upload,/upload/ ssl = false -localPath = true +localPath = false diff --git a/services/upload/uploadService.js b/services/upload/uploadService.js index ca02e13c..1c6c2d5f 100644 --- a/services/upload/uploadService.js +++ b/services/upload/uploadService.js @@ -83,7 +83,8 @@ app.post("/upload", upload.array("uploads[]", 12), function (req, res) { app.post('/upload/:id', upload.single('photo'), (req, res) => { const token = req.headers['x-xsrf-token']; const file = req.file; - const filepath = "./" + file.path; + var filepath = (localPath?".":__dirname)+"/" + file.path; + console.log(filepath); if(!token) { res.status(401).send(getResponse(401, "Unauthorized")); deleteFile(filepath); @@ -126,7 +127,11 @@ app.get('/tiny', function (req, res) { TinyURL.shorten(req.query.url, function(res1, err) { if (err) console.log(err) - res.send(res1); + if(res1 !== 'Error') { + res.send(res1); + } else { + res.send(req.query.url); + } }); });