[Trunk| Services: utils]
add file with production properties UPload: add parameter type (default is csv) allow upload of json Check for post: Split url to ? in case it contains query parameters git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-portal/trunk@57871 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
parent
2f1207b56d
commit
05a7e9560e
|
@ -1,4 +1,14 @@
|
|||
#uncomment properties file based on deployment environment
|
||||
#mv beta-properties.file properties.file
|
||||
#mv production-properties.file properties.file
|
||||
|
||||
#rm -rf node_modules/ run.sh uploads/ .idea/
|
||||
#rm prepareDeploy.sh
|
||||
|
||||
#Copy files to beta.explore.openaire.eu or explore.openaire.eu /home/argiro.kokogiannaki/portals/utils-service.YYYY-MM-DD
|
||||
# run npm i
|
||||
#change to user nodejs " sudo su nodejs -s /bin/bash"
|
||||
#copy files to deploy folder " cp -r /home/argiro.kokogiannaki/portals/utils-service.YYY-MM-DD/* /srv/www/upload/"
|
||||
# restart uplication "pm2 restart upload"
|
||||
|
||||
#rm -rf node_modules/ run.sh uploads/
|
||||
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
userInfoUrl = https://services.openaire.eu/uoa-user-management/api/users/getUserInfo?accessToken=
|
||||
originServer = .openaire.eu
|
||||
post.allowed = /upload,/upload/
|
||||
ssl = true
|
||||
localPath = false
|
||||
# photo size in KB
|
||||
photo.size = 200
|
|
@ -42,7 +42,7 @@ app.use(bodyParser.urlencoded({extended: true}));
|
|||
app.use(cookieParser());
|
||||
|
||||
app.use(function (req, res, next) {
|
||||
if((req.method === 'POST' || req.method === 'DELETE') && allowPostRequests.indexOf(req.url) === -1) {
|
||||
if((req.method === 'POST' || req.method === 'DELETE') && allowPostRequests.indexOf(req.url.split('?')[0]) === -1) {
|
||||
if(checkCookies(req)) {
|
||||
res.header('Access-Control-Allow-Origin', req.headers.origin);
|
||||
res.header('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept, x-xsrf-token');
|
||||
|
@ -54,7 +54,7 @@ app.use(function (req, res, next) {
|
|||
res.header('Vary', 'Origin');
|
||||
res.status(403).send(getResponse(403, "Forbidden: You don't have permission to access. Maybe you are not registered."));
|
||||
}
|
||||
} else if(req.method === 'OPTIONS' && allowPostRequests.indexOf(req.url) === -1){
|
||||
} else if(req.method === 'OPTIONS' && allowPostRequests.indexOf(req.url.split('?')[0]) === -1){
|
||||
res.header('Access-Control-Allow-Origin', req.headers.origin);
|
||||
res.header('Access-Control-Allow-Credentials', true);
|
||||
res.header('Access-Control-Allow-Methods', 'POST, DELETE');
|
||||
|
@ -70,7 +70,12 @@ app.use(function (req, res, next) {
|
|||
|
||||
app.post("/upload", upload.array("uploads[]", 12), function (req, res) {
|
||||
var filepath = (localPath?".":__dirname)+"/" + req.files[0].path;
|
||||
if (req.files[0].mimetype !== 'text/csv' && req.files[0].mimetype !== 'application/vnd.ms-excel') {
|
||||
let type = req.query.type;
|
||||
console.log(type);
|
||||
if(type == 'json' && req.files[0].mimetype !== 'application/json'){
|
||||
console.error("No proper file type");
|
||||
res.status(500).send(getResponse(500, "No proper file type"));
|
||||
}else if ((!type || type == 'csv') && req.files[0].mimetype !== 'text/csv' && req.files[0].mimetype !== 'application/vnd.ms-excel') {
|
||||
console.error("No proper file type");
|
||||
res.status(500).send(getResponse(500, "No proper file type"));
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue