[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
This commit is contained in:
k.triantafyllou 2019-06-27 13:44:54 +00:00
parent 44dc17c6c1
commit 7b07addaf5
2 changed files with 8 additions and 3 deletions

View File

@ -2,4 +2,4 @@ userInfoUrl = http://scoobydoo.di.uoa.gr:8080/dnet-openaire-users-1.0.0-SNAPSHOT
originServer = .di.uoa.gr originServer = .di.uoa.gr
post.allowed = /upload,/upload/ post.allowed = /upload,/upload/
ssl = false ssl = false
localPath = true localPath = false

View File

@ -83,7 +83,8 @@ app.post("/upload", upload.array("uploads[]", 12), function (req, res) {
app.post('/upload/:id', upload.single('photo'), (req, res) => { app.post('/upload/:id', upload.single('photo'), (req, res) => {
const token = req.headers['x-xsrf-token']; const token = req.headers['x-xsrf-token'];
const file = req.file; const file = req.file;
const filepath = "./" + file.path; var filepath = (localPath?".":__dirname)+"/" + file.path;
console.log(filepath);
if(!token) { if(!token) {
res.status(401).send(getResponse(401, "Unauthorized")); res.status(401).send(getResponse(401, "Unauthorized"));
deleteFile(filepath); deleteFile(filepath);
@ -126,7 +127,11 @@ app.get('/tiny', function (req, res) {
TinyURL.shorten(req.query.url, function(res1, err) { TinyURL.shorten(req.query.url, function(res1, err) {
if (err) if (err)
console.log(err) console.log(err)
res.send(res1); if(res1 !== 'Error') {
res.send(res1);
} else {
res.send(req.query.url);
}
}); });
}); });