X-Git-Url: https://osm.etsi.org/gitweb/?p=osm%2FUI.git;a=blobdiff_plain;f=skyquake%2Fplugins%2Fcomposer%2Fapi%2Fcomposer.js;h=e9e4be1da2bf96bbfd4c79d2284742098093f014;hp=5ff92c80ea9559e38288198127b04150f61bf832;hb=3ba614b5a41ca41bdecd4d1e63697277f31c4bdb;hpb=b882ecd7bca6965de18bca855d54f699131da34d diff --git a/skyquake/plugins/composer/api/composer.js b/skyquake/plugins/composer/api/composer.js index 5ff92c80e..e9e4be1da 100644 --- a/skyquake/plugins/composer/api/composer.js +++ b/skyquake/plugins/composer/api/composer.js @@ -523,6 +523,9 @@ PackageManager.getJobStatus = function(req) { }) } +function makeAssetTypeParamName (type) { + return type.toLowerCase() + '-file-type'; +} FileManager.addFile = function(req) { console.log(' Uploading file', req.file.originalname, 'as', req.file.filename); var api_server = req.query['api_server']; @@ -530,15 +533,17 @@ FileManager.addFile = function(req) { var package_id = req.query['package_id']; var package_type = req.query['package_type'].toUpperCase(); var package_path = req.query['package_path']; - if (!download_host) { + if (!download_host) { download_host = req.protocol + '://' + req.get('host');//api_server + ':' + utils.getPortForProtocol(req.protocol); } var input = { 'external-url': download_host + '/composer/upload/' + req.query['package_id'] + '/' + req.file.filename, 'package-type': package_type, 'package-id': package_id, - 'package-path': package_path + '/' + req.file.filename + 'package-path': package_path ? package_path + '/' + req.file.filename : req.file.filename } + var assetType = req.query['asset_type'].toUpperCase(); + input[makeAssetTypeParamName(package_type)] = assetType; return new Promise(function(resolve, reject) { Promise.all([ rp({ @@ -580,16 +585,17 @@ FileManager.get = function(req) { var id = req.query['package_id']; var downloadUrl = req.query['url']; var path = req.query['package_path']; - var payload = { - "input": { - "package-type": type, - "package-id": id - } + var assetType = req.query['asset_type']; + var input = { + "package-type": type, + "package-id": id } + var payload = {input: input}; if(req.method == 'GET') { if(downloadUrl && path) { payload.input['external-url'] = downloadUrl; payload.input['package-path'] = path; + payload.input[makeAssetTypeParamName(type)] = assetType; return download(payload); } else { return list(payload); @@ -597,6 +603,7 @@ FileManager.get = function(req) { } if(req.method == 'DELETE') { payload.input['package-path'] = path; + payload.input[makeAssetTypeParamName(type)] = assetType; return deleteFile(payload) }